require service { const vector string month_name = vector { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; const html CalendarDoc =

Calendar


<<<<[month]> <[year]>>>>

today: <[today]>
<[next_tr]>
MonTuesWedThurFriSatSun

Done ; const html WeekRowDoc = <[next_day]> <[next_tr]> ; const html NoDayDoc =   <[next_day]> ; const html DayDoc = <[day]>
<[content]> <[next_day]> ; const html Thanks = Thank you for using the Calendar. ; string prettyMonth(time t) { return month_name[getMonth(t)-1]; } string today() { time t = now(); return prettyMonth(t)+" "+getDay(t)+", "+getYear(t); } html showMonth(time t) { int i, month, weekday; time t2; html H; t2 = setDay(t,1); month = getMonth(t); weekday = getWeekday(t2); H = CalendarDoc <[month = prettyMonth(t), year = getYear(t), today = today()]; H = H <[next_tr = WeekRowDoc]; for (i=1; i1 && i<=7; i++) H = H <[next_day = NoDayDoc]; return H; } session Calendar() { int num_months; time t; t = setDay(now(),1); repeat { show showMonth(t) receive [num_months = continue]; t = setMonth(t,getMonth(t)+num_months); if (t==notime) t = now(); } until (num_months==0); exit Thanks; } }