reverse_day_number(+Year, +DayNumber, ?Month, ?Day)

Calculate the month and day for a specified day number of a year. A day number is the number of days since 1-1 of a Year. A day number is not equal to a date number, a date number uniquely identifies a day since 1-1-1.

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 prev_week/4 start_of_week/3

Example
reverse_day_number(1998, 100, Month, Day). The day number for the first day of a year is 1, this number is unified with DayNum, DayNum = 1
reverse_day_number(2000, 34, Month, Day). Succeeds because the daynumber for 31 Jan 2000 is 31.
reverse_day_number(2000, 34, 5, DayNum). The day number for the last day of the year 2000 is 366, this number is unified with DayNum, DayNum = 366

 

Exceptions  
The Year and DayNumber parameters are not integers a type_error(evaluable, Value) exception is thrown, Value is unified with the incorrect argument
The Month and/or Day parameters are not integers nor variables a type_error(evaluable, Value) exception is thrown, Value is unified with the incorrect argument

 

 

info@trinc-prolog.com