The Calendar Module of Python
The calendar module provides calendar features, including printing functions for a specific month or year.
Default is the first day of the week on Monday and the last day on Sunday on Sunday. Call calendar.setfirstweekday() to modify this. The calendar module provides calendar features, including printing functions for a specific month or year.
Default is the first day of the week on Monday and the last day on Sunday on Sunday. callcalendar.setfirstweekday() to modify this.
SN
Function with Description
1
calendar.calendar(year,w=2,l=1,c=6)
Returns an annual multiline string structured in three columns with c spaces. W is the width for each date character; each line is 21*w+18+2*c in length. | is the weekly number of lines.
2
calendar.firstweekday()
Returns the current weekday setting that begins every week. Default is 0, signifying Monday, when calendar is initially imported.
3
calendar.isleap(year)
Returns True if a year is a savings year, False if not.
4
calendar.leapdays(y1,y2)
Returns the total number of leap days in the years within range (y1,y2).
5
calendar.month(year, month,w=2,l=1)
Returns a multiline calendar, one line a week plus two header lines, for a month of the year. w is the width in each date character, each line is 7*w+6 in length.
6
calendar.monthcalendar(year,month)
The lists of the ints are returned. There is a week in each sublist. The days outside the month of the year shall be 0; the days within the month shall be 1 and up.
7
calendar.monthrange(year,month)
Two integer returns. The first is the weekday code for the first day of the month in the year, while the second indicates the number of days in the month. Codes for weekdays are from 0 (Monday) to 6 (Sunday); number of month is from 1 to 12.
8
calendar.prcal(year,w=2,l=1,c=6)
Like print calendar.calendar(year,w,l,c)
9
calendar.prmonth(year,month,w=2,l=1)
Like print calendar.month(year,month,w,l)
10
calendar.timegm(tupletime)
Sets the weekly code on the first day of each week. Weekday codes are between 0(Monday) and 6 (Sunday).
11
calendar.timegm(tupletime)
The other way around. gmtime: takes an instant time as a timestamp and returns the same instant as a number of seconds floating in points since that time.
12
Calendar.weekday(year,month,day)
The weekday code for the date specified is returned. The codes of weekdays shall be 0(Monday) to 6(Sunday); the number of months shall be 1(Jan.) to 12. (December).
In this module, the methods and classes used an idealistic calendar. The present Gregorian calendar extends endlessly to both directions, which corresponds to the "proleptic Gregorian calendar" concept used by Dershowitz and Reingold's book Calendar Calculations. Null years and negative years are construed according to the norm ISO 8601. 1 BC is the year 0, 2 BC is the year 0, etc... The year 0.
The calendar of classes.
Calendar(firstweekday=0)
Make an item for a calendar. The first weekday is an integer indicating the week's first day, and the default is Monday (0) and Sunday (6).
iterweekdays()
Return a number of the weekday iterator utilized for one week. The first value of the iterator is the same as that of the property of the first weekday.
Dates of the hour (year, month)
Return the month iterator (1–12) in the year. It is returned for each month and any days before or after the beginning of the month that are necessary to produce a complete week (as a datetime. date object).
Monthly hours (year, month)
Return a month iterator in the year like itermonthdates(), but not limited to the date.
Range of dates. The returned days are just the number of days in the month.
The days returned are multiplied by the number of a day of the month and the number of a week of the day.
Hours3 Hours3 (year, month)
Return a month iterator in the year like itermonthdates(), but not limited to the date.
Range of dates. The returned days will be tuples of one year, one month, and one month.
The hours of the month4 (year, month)
Return a month iterator in the year like itermonthdates(), but not limited to the date.
Range of dates. The days returned will include a year, a month, day, and week numbers. Several times tuple would be returned.
Calendar month dates (year, month)
Calendar monthdays2 (year, month)
Return a list of weeks as complete weeks within the month of the year. Weeks are lists of seven times the number of days and the number of days.