41
|
1 """
|
|
2 also see https://madebyevan.com/calendar/app/
|
|
3 https://ui.toast.com/tui-calendar
|
|
4 """
|
40
|
5 import calendar
|
|
6 import datetime
|
|
7 import itertools
|
|
8 import sys
|
|
9
|
|
10 from htmlgenerator import BODY, H1, HEAD, HTML, SPAN, STYLE, TABLE, TBODY, TD, TH, TR, mark_safe, render
|
|
11
|
|
12 c = calendar.TextCalendar(firstweekday=6)
|
|
13
|
|
14 start = datetime.date.today()
|
|
15 start = start - datetime.timedelta(days=start.weekday() + 1)
|
|
16 offset = itertools.count()
|
|
17 currentMonth = -1
|
|
18
|
|
19
|
|
20 def nextDayLabel():
|
|
21 global currentMonth
|
|
22 thisDay = start + datetime.timedelta(days=next(offset))
|
|
23 month = ''
|
|
24 if thisDay.month != currentMonth:
|
|
25 month = f'{calendar.month_name[thisDay.month]} '
|
|
26 currentMonth = thisDay.month
|
|
27 return f'{month}{thisDay.day}'
|
|
28
|
|
29
|
|
30 def weekdayLabels():
|
|
31 row = [TH(c.formatweekday(i, width=100)) for i in c.iterweekdays()]
|
|
32 return TR(*row)
|
|
33
|
|
34
|
|
35 def nextWeekDays():
|
|
36 return TR(*[TD(SPAN(nextDayLabel(), class_="day")) for wd in c.iterweekdays()])
|
|
37
|
|
38
|
|
39 sys.stdout.write(
|
|
40 render(
|
|
41 HTML( #
|
|
42 HEAD(STYLE(mark_safe(open('wall_calendar.css').read()))), #
|
|
43 BODY(H1("todo"), TABLE(*weekdayLabels(), TBODY(*[nextWeekDays() for week in range(8)])))),
|
|
44 {}))
|