* fix calculation of all day events
authorWilfried Göesgens <willi@citadel.org>
Thu, 11 Oct 2007 22:23:53 +0000 (22:23 +0000)
committerWilfried Göesgens <willi@citadel.org>
Thu, 11 Oct 2007 22:23:53 +0000 (22:23 +0000)
* workaround troubles with daylight saving time.

webcit/calendar.c
webcit/calendar_view.c

index 65bb670e70210f09d82d9448ed7e2b0eeed83ac1..f6f1251c390fae7d60610e2967ca50aa8557a4ae 100644 (file)
@@ -471,11 +471,12 @@ void display_individual_cal(icalcomponent *cal, long msgnum)
        if (ps != NULL) {
                t = icalproperty_get_dtstart(ps);
                event_ts = icaltime_as_timet(t);
+
                if (t.is_date) { //! calculate whether we are a day event.
                        Cal->start_hour = -1;
                        Cal->end_hour = -1;
                        Cal->end_day = -1;
-                       gmtime_r(&event_ts, &event); 
+                       localtime_r(&event_ts, &event); 
                        event.tm_sec = 0;
                        event.tm_min = 0;
                        event.tm_hour = 0; 
index f09b6109bb86e902b43ddc32b0110f88dae1bd6a..39ae8685b9e87e4cb71cac1ec75c65b89a003992 100644 (file)
@@ -29,6 +29,7 @@ void calendar_month_view_display_events(time_t thetime) {
        int fill_day_event = 0;
        int show_event = 0;
        time_t tt;
+       time_t dst_day;
        char buf[256];
        struct wcsession *WCC;
        struct disp_cal *Cal;
@@ -44,7 +45,7 @@ void calendar_month_view_display_events(time_t thetime) {
        month = today_tm.tm_mon + 1;
        day = today_tm.tm_mday;
        year = today_tm.tm_year + 1900;
-
+       dst_day = thetime - 3600;
        for (i=0; i<(WCC->num_cal); ++i) {
                fill_day_event = 0;
                multi_day_event = 0;
@@ -52,11 +53,16 @@ void calendar_month_view_display_events(time_t thetime) {
                Cal = &WCC->disp_cal[i];
                all_day_event =  Cal->start_hour == -1;
                show_event = thetime == Cal->start_day;
-               if (Cal->multi_day_event) {
+//             lprintf(1,"Date: %d %d %d %d\n", thetime, Cal->start_day, day, thetime - Cal->start_day);
+               if (!all_day_event) {
 
                        // are we in the range of the event?
                        show_event = (Cal->start_day <= thetime) && 
                                (Cal->end_day >= thetime);
+                       if (!show_event)
+                               // are we in the range of the event?
+                               show_event = (Cal->start_day <= dst_day) && 
+                                       (Cal->end_day >= dst_day);
 
                        // are we not start or end day?
                        fill_day_event = (Cal->start_day < thetime) && 
@@ -300,8 +306,6 @@ void calendar_month_view(int year, int month, int day) {
         * First, back up to the 1st of the month...
         */
        memset(&starting_tm, 0, sizeof(struct tm));
-       if (WC->num_cal > 0) 
-               localtime_r(&WC->disp_cal[0].start_day, &starting_tm);
 
        starting_tm.tm_year = year - 1900;
        starting_tm.tm_mon = month - 1;