Tuesday, September 15, 2009

Python - creating HTML Calendars

# python has an HTML Calendar module!
import calendar

c = calendar.HTMLCalendar()

# produce an HTML calendar for 2009
c.formatyear(2009)
2009

January
MonTueWedThuFriSatSun
1234
567891011
12131415161718
19202122232425
262728293031


February
MonTueWedThuFriSatSun
1
2345678
9101112131415
16171819202122
232425262728


March
MonTueWedThuFriSatSun
1
2345678
9101112131415
16171819202122
23242526272829
3031


April
MonTueWedThuFriSatSun
12345
6789101112
13141516171819
20212223242526
27282930


May
MonTueWedThuFriSatSun
123
45678910
11121314151617
18192021222324
25262728293031


June
MonTueWedThuFriSatSun
1234567
891011121314
15161718192021
22232425262728
2930


July
MonTueWedThuFriSatSun
12345
6789101112
13141516171819
20212223242526
2728293031


August
MonTueWedThuFriSatSun
12
3456789
10111213141516
17181920212223
24252627282930
31


September
MonTueWedThuFriSatSun
123456
78910111213
14151617181920
21222324252627
282930


October
MonTueWedThuFriSatSun
1234
567891011
12131415161718
19202122232425
262728293031


November
MonTueWedThuFriSatSun
1
2345678
9101112131415
16171819202122
23242526272829
30


December
MonTueWedThuFriSatSun
123456
78910111213
14151617181920
21222324252627
28293031

# generate just a month
c.formatmonth(2009, 7)

July 2009
MonTueWedThuFriSatSun
12345
6789101112
13141516171819
20212223242526
2728293031

No comments:

Post a Comment