<%impl> /* vim:set ft=sitecing: */ #include #include really simple page % /* Just call the calendar member function */ % calendar(); <%method void calendar() %> <%code> time_t tt = time(0); struct tm t; if(!localtime_r(&tt,&t)) throw konforka::exception(CODEPOINT,"couldn't fetch current date"); char h[16]; if(strftime(h,sizeof(h),"%B, %Y",&t)>=sizeof(h)) throw konforka::exception(CODEPOINT,"couldn't produce heading for the calendar"); int today = t.tm_mday; t.tm_mday = 1; tt=mktime(&t); if(!localtime_r(&tt,&t)) throw konforka::exception(CODEPOINT,"couldn't fetch current date"); int dim = 31; if(t.tm_mon==3 || t.tm_mon==5 || t.tm_mon==8 || t.tm_mon==10) { dim = 30; }else if(t.tm_mon==1) { dim = (t.tm_year%4)?28:29; } <%code> int dow=0; int dom=1-t.tm_wday; for(;;dom++,dow=(dow+1)%7) { if(!dow) { <%output> } bool be = (dom>=1 && dom<=dim); std::string ec = be?" existant":" unexistant"; if(dom==today) ec+=" today"; <%output> if(dow==6) { <%output> if(dom>=dim) break; } }
<% h %>
Sun Mon Tue Wed Thu Fri Sat
if(be) { <%output><% dom %> } <%output>