* by Feivel: check for day when highlighting weekday
authorWilfried Göesgens <willi@citadel.org>
Sun, 25 Oct 2009 11:07:25 +0000 (11:07 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 25 Oct 2009 11:07:25 +0000 (11:07 +0000)
webcit/calendar_view.c

index 2de090f331471e8549f7e2eb65424a69e79e8c03..191ea78d19b505f9c7053aee3c459b2531a46f48 100644 (file)
@@ -501,15 +501,23 @@ void calendar_month_view_brief_events(time_t thetime, const char *daycolor) {
 void calendar_month_view(int year, int month, int day) {
        struct tm starting_tm;
        struct tm tm;
+       struct tm today_tm;
        time_t thetime;
        int i;
        time_t previous_month;
        time_t next_month;
        time_t colheader_time;
+       time_t today_timet;
        struct tm colheader_tm;
        char colheader_label[32];
        long weekstart = 0;
 
+       /*
+        * Make sure we know which day is today.
+        */
+       today_timet = time(NULL);
+       localtime_r(&today_timet, &today_tm);
+
        /*
         * Determine what day to start.  If an impossible value is found, start on Sunday.
         */
@@ -599,7 +607,7 @@ void calendar_month_view(int year, int month, int day) {
 
                wc_printf("<td class=\"cal%s\"><div class=\"day\">",
                        ((tm.tm_mon != month-1) ? "out" :
-                               ((tm.tm_mday == day) ? "today" :
+                               (((tm.tm_year == today_tm.tm_year) && (tm.tm_mon == today_tm.tm_mon) && (tm.tm_mday == today_tm.tm_mday)) ? "today" :
                                ((tm.tm_wday==0 || tm.tm_wday==6) ? "weekend" :
                                        "day")))
                        );