Module calendar
[hide private]
[frames] | no frames]

Module 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).

Classes [hide private]
IllegalMonthError
IllegalWeekdayError
_localized_month
_localized_day
Calendar
Base calendar class.
TextCalendar
Subclass of Calendar that outputs a calendar as a simple plain text similar to the UNIX program cal.
HTMLCalendar
This calendar returns complete HTML pages.
TimeEncoding
LocaleTextCalendar
This class can be passed a locale name in the constructor and will return month and weekday names in the specified locale.
LocaleHTMLCalendar
This class can be passed a locale name in the constructor and will return month and weekday names in the specified locale.
Functions [hide private]
 
isleap(year)
Return 1 for leap years, 0 for non-leap years.
 
leapdays(y1, y2)
Return number of leap years in range [y1, y2).
 
weekday(year, month, day)
Return weekday (0-6 ~ Mon-Sun) for year (1970-...), month (1-12), day (1-31).
 
monthrange(year, month)
Return weekday (0-6 ~ Mon-Sun) and number of days (28-31) for year, month.
 
firstweekday()
 
setfirstweekday(firstweekday)
 
monthcalendar(year, month)
Return a matrix representing a month's calendar.
 
prweek(theweek, width)
Print a single week (no newline).
 
week(theweek, width)
Returns a single week in a string (no newline).
 
weekheader(width)
Return a header for a week.
 
prmonth(theyear, themonth, w=0, l=0)
Print a month's calendar.
 
month(theyear, themonth, w=0, l=0)
Return a month's calendar string (multi-line).
 
calendar(theyear, w=2, l=1, c=6, m=3)
Returns a year's calendar as a multi-line string.
 
prcal(theyear, w=0, l=0, c=6, m=3)
Print a year's calendar.
 
format(cols, colwidth=20, spacing=6)
Prints multi-column formatting for year calendars
 
formatstring(cols, colwidth=20, spacing=6)
Returns a string formatted from n strings, centered within n columns.
 
timegm(tuple)
Unrelated but handy function to calculate Unix timestamp from GMT.
 
main(args)
Variables [hide private]
  January = 1
  February = 2
  mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
  day_name = _localized_day('%A')
  day_abbr = _localized_day('%a')
  month_name = _localized_month('%B')
  month_abbr = _localized_month('%b')
  c = TextCalendar()
  _colwidth = 20
  _spacing = 6
  EPOCH = 1970
  _EPOCH_ORD = 719163
  FRIDAY = 4
  MONDAY = 0
  SATURDAY = 5
  SUNDAY = 6
  THURSDAY = 3
  TUESDAY = 1
  WEDNESDAY = 2

Imports: sys, datetime, locale, error


Function Details [hide private]

leapdays(y1, y2)

 

Return number of leap years in range [y1, y2). Assume y1 <= y2.

monthcalendar(year, month)

 

Return a matrix representing a month's calendar. Each row represents a week; days outside this month are zero.