+
+void calendar_month_view(int year, int month, int day) {
+ struct tm starting_tm;
+ struct tm *tm;
+ time_t thetime;
+ int i;
+ time_t previous_month;
+ time_t next_month;
+
+ /* Determine what day to start.
+ * First, back up to the 1st of the month...
+ */
+ memset(&starting_tm, 0, sizeof(struct tm));
+ starting_tm.tm_year = year - 1900;
+ starting_tm.tm_mon = month;
+ starting_tm.tm_mday = day;
+ thetime = mktime(&starting_tm);
+
+ tm = &starting_tm;
+ while (tm->tm_mday != 1) {
+ thetime = thetime - (time_t)86400; /* go back 24 hours */
+ tm = localtime(&thetime);
+ }
+
+ /* Determine previous and next months ... for links */
+ previous_month = thetime - (time_t)864000L; /* back 10 days */
+ next_month = thetime + (time_t)(31L * 86400L); /* ahead 31 days */
+
+ /* Now back up until we're on a Sunday */
+ tm = localtime(&thetime);
+ while (tm->tm_wday != 0) {
+ thetime = thetime - (time_t)86400; /* go back 24 hours */
+ tm = localtime(&thetime);
+ }
+
+ wprintf("<CENTER><H2>");
+
+ tm = localtime(&previous_month);
+ wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
+ (int)(tm->tm_year)+1900, tm->tm_mon);
+ wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/back.gif\" BORDER=0></A>\n");
+
+ wprintf(" %s %d ", months[month], year);
+
+ tm = localtime(&next_month);
+ wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
+ (int)(tm->tm_year)+1900, tm->tm_mon + 1);
+ wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/forward.gif\" BORDER=0></A>\n");
+
+ wprintf("</H2>");
+
+ wprintf("<TABLE border=1 width=100%%>");
+ for (i=0; i<7; ++i) {
+ wprintf("<TH>%s</TH>", days[i]);
+ }
+
+ /* Now do 35 days */
+ for (i = 0; i < 35; ++i) {
+ tm = localtime(&thetime);
+ if (tm->tm_wday == 0) {
+ wprintf("<TR>");
+ }
+
+ wprintf("<TD>");
+ if ((i==0) || (tm->tm_mday == 1)) {
+ wprintf("%s ", months[tm->tm_mon]);
+ }
+ wprintf("%d", tm->tm_mday);
+
+ /* FIXME ... put the data here, stupid */
+ wprintf("<BR><BR><BR>");
+
+ wprintf("</TD>");
+
+ if (tm->tm_wday == 6) {
+ wprintf("</TR>\n");
+ }
+
+ thetime += (time_t)86400; /* ahead 24 hours */
+ }
+
+ wprintf("</TABLE></CENTER>\n");
+}
+
+
+void calendar_week_view(int year, int month, int day) {
+ wprintf("<CENTER><I>week view FIXME</I></CENTER><BR>\n");
+}
+
+
+void calendar_day_view(int year, int month, int day) {
+ wprintf("<CENTER><I>day view FIXME</I></CENTER><BR>\n");
+}
+
+
+