* Fixed buggy month-selection algorithm (January is month 0 in 'struct tm' but
authorArt Cancro <ajc@citadel.org>
Thu, 26 Sep 2002 22:00:16 +0000 (22:00 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 26 Sep 2002 22:00:16 +0000 (22:00 +0000)
  month 1 in libical functions)

webcit/ChangeLog
webcit/calendar_view.c

index d8b275f377170d49bec38e5d7868611af93812bd..575343e36c255d84e2018930a785f342e20c0d77 100644 (file)
@@ -1,4 +1,8 @@
 $Log$
+Revision 400.25  2002/09/26 22:00:16  ajc
+* Fixed buggy month-selection algorithm (January is month 0 in 'struct tm' but
+  month 1 in libical functions)
+
 Revision 400.24  2002/09/25 21:57:13  ajc
 * Keep track of msgnums in the two-pass calendar loop, so we can hotlink to
   individual items
@@ -1023,3 +1027,4 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
+
index 0c8cc49a5419d6c7c5fbf0de07f76e2b49b5f668..b23685dc279f3f26b3c181520a64fe84fb43168f 100644 (file)
@@ -92,7 +92,7 @@ void calendar_month_view(int year, int month, int day) {
         */
        memset(&starting_tm, 0, sizeof(struct tm));
        starting_tm.tm_year = year - 1900;
-       starting_tm.tm_mon = month;
+       starting_tm.tm_mon = month - 1;
        starting_tm.tm_mday = day;
        thetime = mktime(&starting_tm);
        lprintf(9, "Starting at %s", asctime(localtime(&thetime)));
@@ -126,14 +126,14 @@ void calendar_month_view(int year, int month, int day) {
 
        tm = localtime(&previous_month);
        wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
-               (int)(tm->tm_year)+1900, tm->tm_mon);
+               (int)(tm->tm_year)+1900, tm->tm_mon + 1);
        wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/back.gif\" BORDER=0></A>\n");
 
        wprintf("&nbsp;&nbsp;"
                "<FONT COLOR=#FFFFFF>"
                "%s %d"
                "</FONT>"
-               "&nbsp;&nbsp;", months[month], year);
+               "&nbsp;&nbsp;", months[month-1], year);
 
        tm = localtime(&next_month);
        wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
@@ -192,15 +192,33 @@ void calendar_week_view(int year, int month, int day) {
 
 
 void calendar_day_view(int year, int month, int day) {
-       wprintf("<CENTER><I>FIXME day view for %02d/%02d/%04d</I></CENTER><BR>\n", month, day, year);
+       struct tm starting_tm;
+       time_t thetime;
 
+       /* Determine what day we're viewing.
+        */
+       memset(&starting_tm, 0, sizeof(struct tm));
+       starting_tm.tm_year = year - 1900;
+       starting_tm.tm_mon = month - 1;
+       starting_tm.tm_mday = day;
+       thetime = mktime(&starting_tm);
+       lprintf(9, "Starting at %s", asctime(localtime(&thetime)));
+
+       /* put the data here, stupid */
+       calendar_month_view_display_events(thetime);
 
+       wprintf("<CENTER><I>FIXME day view for %02d/%02d/%04d</I>"
+               "</CENTER><BR>\n", month, day, year);
        wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">"
                "Back to month view</A><BR>\n", year, month);
+
+
 }
 
 
 
+
+
 void do_calendar_view(void) {
        int i;
        time_t now;
@@ -212,7 +230,7 @@ void do_calendar_view(void) {
        now = time(NULL);
        tm = localtime(&now);
        year = tm->tm_year + 1900;
-       month = tm->tm_mon;
+       month = tm->tm_mon + 1;
        day = tm->tm_mday;
 
        /* Now see if a date was specified */
@@ -247,6 +265,7 @@ void do_calendar_view(void) {
        free(WC->disp_cal);
        WC->disp_cal = NULL;
        free(WC->cal_msgnum);
+       WC->cal_msgnum = NULL;
 }