day_of_week(+DateNumber, ?DayOfWeek)

Calculate the day-of-week number for a specified DateNumber. Sunday of a week is defined as the number 1, Monday is 2, Tuesday is 3, Wednesday is 4, Thursday is 5, Friday is 6 and Saturday is 7.

This predicate is located in the file 'datetime.txt', use ensure_loaded/1 to include this file.

see also: age/7 day_number/4 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 reverse_day_number/4 start_of_week/3

Example
day_of_week(730485, Day). succeeds, the date number of the last day of 2000 (31-dec-2000) is 730485, the calculated day-of-week number is 1, this value is unified with Day, (the last day of 2000 was a sunday)
Day = 1
day_of_week(730485, 2). fails because the last day of 2000 (31-dec-2000) was a sunday and not a monday

 

Exceptions  
DayNumber or DayOfWeek is not an integer a type_error(evaluable, Value) exception is thrown, Value is unified with the incorrect argument

 

 

info@trinc-prolog.com