Determine the week number of the previous week, the first two parameters are input parameters, these are a year and a week number. The last two parameters are the year and week number of the previous week. This predicate is useful when it is necessary to iterate through a number of weeks from a certain week number of a year.
There is also the predicate next_week/4 to determine the week number of a next week. This predicate is located in the file 'datetime.txt', use ensure_loaded/1 to include this file.
see also: age/7 day_number/4 day_of_week/2 datetime module decode_date/4 decode_datetime/7 decode_time/4 encode_date/4 encode_datetime/7 encode_time/2 encode_time/3 encode_time/4 ensure_loaded/1 first_week/2 leap_year/1 length_month/3 monday_of_week/3 monday_of_week/5 next_week/4 num_weeks_in_year/2 reverse_day_number/4 start_of_week/3
| Example | |
| prev_week(1998, 1, Y, W). | succeeds and the week and year numbers are: Y = 1997, W = 52 |
| prev_week(1997, 52, Y, W). | succeeds, the previous week of week 52 of 1997 is: Y = 1997, W = 51 |
| prev_week(1999, 1, 1998, 52). | fails, because 1998 has 53 weeks |
| prev_week(2000, 1, 1999, 52). | succeeds, because 1999 has 52 weeks |
| Exceptions | |
| The Year and/or WeekNumber parameters are not integers | a type_error(evaluable, Value) exception is thrown, Value is unified with the incorrect argument |