w3resource

Python Calendar Module: yeardayscalendar() method

yeardayscalendar() method

The yeardayscalendar() method is used to get the data for the specified year ready for formatting. The method is similar to yeardatescalendar().
Entries in the week lists are day numbers. Day numbers outside this month are zero.

Syntax:

yeardayscalendar(year, width=3)

Parameters:

Name Description Required /
Optional
Type
year Year for which the calendar should be generated. Required Number
width The number of months to include in each row. Default: 3 Required Number

Example of yeardayscalendar() method

import calendar
cal= calendar.Calendar()
print(cal.yeardayscalendar(2016, 5))

Output

[[[[0, 0, 0, 0, 1, 2, 3], 
[4, 5, 6, 7, 8, 9, 10], 
[11, 12, 13, 14, 15, 16, 17], 
[18, 19, 20, 21, 22, 23, 24], 
[25, 26, 27, 28, 29, 30, 31]], 
[[1, 2, 3, 4, 5, 6, 7], 
[8, 9, 10, 11, 12, 13, 14], 
[15, 16, 17, 18, 19, 20, 21],
[22, 23, 24, 25, 26, 27, 28], 
[29, 0, 0, 0, 0, 0, 0]], 
............................
[[0, 0, 0, 1, 2, 3, 4], 
[5, 6, 7, 8, 9, 10, 11], 
[12, 13, 14, 15, 16, 17, 18], 
[19, 20, 21, 22, 23, 24, 25], 
[26, 27, 28, 29, 30, 31, 0]]]]

Previous: yeardays2calendar()
Next: formatmonth()

Test your Python skills with w3resource's quiz



Follow us on Facebook and Twitter for latest update.