Sunday, 26 June 2016

Python: Calendar: itermonthdates(year, month)

itermonthdates(year, month)

Returns an iterator for the given month in given year. In addition to return all days for the month, it returns all days before the start of the month or after the end of the month that are required to get a complete week.

>>> from calendar import Calendar, SUNDAY
>>> cal1=Calendar()
>>> iter=cal1.itermonthdates(2015, 11)
>>> for day in iter:
...     print(day)
... 
2015-10-26
2015-10-27
2015-10-28
2015-10-29
2015-10-30
2015-10-31
2015-11-01
2015-11-02
2015-11-03
2015-11-04
2015-11-05
2015-11-06
2015-11-07
2015-11-08
2015-11-09
2015-11-10
2015-11-11
2015-11-12
2015-11-13
2015-11-14
2015-11-15
2015-11-16
2015-11-17
2015-11-18
2015-11-19
2015-11-20
2015-11-21
2015-11-22
2015-11-23
2015-11-24
2015-11-25
2015-11-26
2015-11-27
2015-11-28
2015-11-29
2015-11-30
2015-12-01
2015-12-02
2015-12-03
2015-12-04
2015-12-05
2015-12-06


Previous                                                 Next                                                 Home

No comments:

Post a Comment