calendar¶
Calendar printing functions
Note when comparing these calendars to the ones printed by cal(1): By default, these calendars have Monday as the first day of the week, and Sunday as the last (the European convention). Use setfirstweekday() to set the first day of the week (0=Monday, 6=Sunday).
Functions¶
format(cols[, colwidth, spacing]) |
Prints multi-column formatting for year calendars |
formatstring(cols[, colwidth, spacing]) |
Returns a string formatted from n strings, centered within n columns. |
isleap(year) |
Return True for leap years, False for non-leap years. |
leapdays(y1, y2) |
Return number of leap years in range [y1, y2). |
main(args) |
|
monthrange(year, month) |
Return weekday (0-6 ~ Mon-Sun) and number of days (28-31) for year, month. |
setfirstweekday(firstweekday) |
|
timegm(tuple) |
Unrelated but handy function to calculate Unix timestamp from GMT. |
weekday(year, month, day) |
Return weekday (0-6 ~ Mon-Sun) for year (1970-...), month (1-12), day (1-31). |
Classes¶
Calendar([firstweekday]) |
Base calendar class. |
HTMLCalendar([firstweekday]) |
This calendar returns complete HTML pages. |
LocaleHTMLCalendar([firstweekday, locale]) |
This class can be passed a locale name in the constructor and will return month and weekday names in the specified locale. |
LocaleTextCalendar([firstweekday, locale]) |
This class can be passed a locale name in the constructor and will return month and weekday names in the specified locale. |
TextCalendar([firstweekday]) |
Subclass of Calendar that outputs a calendar as a simple plain text similar to the UNIX program cal. |
TimeEncoding(locale) |
Exceptions¶
IllegalMonthError(month) |
|
IllegalWeekdayError(weekday) |
|
error |
alias of ValueError |