Friday 1 July 2016

Python: Calendar: monthdatescalendar(year, month)

monthdatescalendar(year, month)

Returns list of the weeks in given month and year as full weeks. Weeks are lists of seven datetime.date objects.
>>> from calendar import Calendar
>>> iter=cal1.monthdatescalendar(2015, 11)
>>> for day in iter:
...     print(day)
... 
[datetime.date(2015, 10, 26), datetime.date(2015, 10, 27), datetime.date(2015, 10, 28), datetime.date(2015, 10, 29), datetime.date(2015, 10, 30), datetime.date(2015, 10, 31), datetime.date(2015, 11, 1)]
[datetime.date(2015, 11, 2), datetime.date(2015, 11, 3), datetime.date(2015, 11, 4), datetime.date(2015, 11, 5), datetime.date(2015, 11, 6), datetime.date(2015, 11, 7), datetime.date(2015, 11, 8)]
[datetime.date(2015, 11, 9), datetime.date(2015, 11, 10), datetime.date(2015, 11, 11), datetime.date(2015, 11, 12), datetime.date(2015, 11, 13), datetime.date(2015, 11, 14), datetime.date(2015, 11, 15)]
[datetime.date(2015, 11, 16), datetime.date(2015, 11, 17), datetime.date(2015, 11, 18), datetime.date(2015, 11, 19), datetime.date(2015, 11, 20), datetime.date(2015, 11, 21), datetime.date(2015, 11, 22)]
[datetime.date(2015, 11, 23), datetime.date(2015, 11, 24), datetime.date(2015, 11, 25), datetime.date(2015, 11, 26), datetime.date(2015, 11, 27), datetime.date(2015, 11, 28), datetime.date(2015, 11, 29)]
[datetime.date(2015, 11, 30), datetime.date(2015, 12, 1), datetime.date(2015, 12, 2), datetime.date(2015, 12, 3), datetime.date(2015, 12, 4), datetime.date(2015, 12, 5), datetime.date(2015, 12, 6)]


Previous                                                 Next                                                 Home

No comments:

Post a Comment