w3resource

Python Calendar Module : yeardatescalendar() method

yeardatescalendar() method

The yeardatescalendar() method is used to get the data for the specified year ready for formatting.
The return value is a list of month rows. Each month row contains up to width months.
Each month contains between 4 and 6 weeks and each week contains 1–7 days. Days are datetime.date objects.

Syntax:

yeardatescalendar(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 yeardatescalendar() method

import calendar
cal= calendar.Calendar()
print(cal.yeardatescalendar(2016, 3))

Output:

[[[[datetime.date(2015, 12, 28), datetime.date(2015, 12, 29), datetime.date(2015, 12, 30), 
datetime.date(2015, 12, 31), datetime.date(2016, 1, 1), datetime.date(2016, 1, 2),
datetime.date(2016, 1, 3)], [datetime.date(2016, 1, 4), datetime.date(2016, 1, 5),
datetime.date(2016, 1, 6), datetime.date(2016, 1, 7), datetime.date(2016, 1, 8), 
datetime.date(2016, 1, 9), datetime.date(2016, 1, 10)],
 ... , 
datetime.date(2016, 12, 27), datetime.date(2016, 12, 28), datetime.date(2016, 12, 29), 
datetime.date(2016, 12, 30), datetime.date(2016, 12, 31), datetime.date(2017, 1, 1)]]]]

Previous: monthdayscalendar()
Next: yeardays2calendar()

Test your Python skills with w3resource's quiz



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://198.211.115.131/python/module/calendar/yeardatescalendar.php