classmethod TimeDuration.days_in_month(year, month, calendar=None, leap_month=2, month_lengths=None)[source]

The number of days in a specific month in a specific year in a specific calendar.

New in version 1.4.

year: int

The calendar year to query.

month: int

The one- or two-digit integer representing the calendar month to query (numbered by order in the calendar year, for example 2 for February, 10 for October).

calendar: str, optional

By default, calendar is the mixed Gregorian/Julian calendar as defined by Udunits.

leap_month: int, optional

The leap month. By default the leap month is 2, i.e. the second month of the year.

month_lengths: sequence of int, optional

By default, month_lengths is [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31].


The number of days in the specified month.


>>> cf.TimeDuration.days_in_month(2004, 2, calendar='360_day')