length_month(+Year, +Month, ?Days)

Determine the number of days of a month. The year and month must be specified because the number of days in February is 29 for leap years and 28 for normal years. The number of the first month is 1.

1 January
2 February
3 March
4 April
5 May
6 June
7 July
8 August
9 September
10 October
11 November
12 December

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 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
length_month(1996, 2, Days). succeeds and the parameter Days is unified with the value 29
Days = 29
length_month(1997, 2, Days). succeeds and the parameter Days is unified with the value 28
Days = 28
length_month(1997, 2, 30). fails because February has 28 days in 1997 and not 30 days

 

 

info@trinc-prolog.com