5.9 calendar -- General calendar-related functions

This module allows you to output calendars like the Unix cal program, and provides additional useful functions related to the calendar.

isleap (year)
Returns true if year is a leap year.

leapdays (year1, year2)
Return the number of leap years in the range [year1...year2].

weekday (year, month, day)
Returns the day of the week (0 is Monday) for year (1970-...), month (1-12), day (1-31).

monthrange (year, month)
Returns weekday of first day of the month and number of days in month, for the specified year and month.

monthcalendar (year, month)
Returns a matrix representing a month's calendar. Each row represents a week; days outside of the month a represented by zeros.

prmonth (year, month[, width[, length]])
Prints a month's calendar. If width is provided, it specifies the width of the columns that the numbers are centered in. If length is given, it specifies the number of lines that each week will use.

prcal (year)
Prints the calendar for the year year.

timegm (tuple)
An unrelated but handy function that takes a time tuple such as returned by the gmtime() function in the time module, and returns the corresponding Unix timestamp value, assuming an epoch of 1970, and the POSIX encoding. In fact, time.gmtime() and timegm() are each others' inverse.

See Also:

Module time:
Low-level time related functions.


Send comments on this document to python-docs@python.org.