[evolution-data-server] Bug 696047 - [alarm-notify] Busy loop on midnight and DST change



commit bbd185e98b410e329634cf7d180d00928e76d621
Author: Milan Crha <mcrha redhat com>
Date:   Mon Oct 16 18:59:42 2017 +0200

    Bug 696047 - [alarm-notify] Busy loop on midnight and DST change

 src/calendar/libecal/e-cal-time-util.c |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/src/calendar/libecal/e-cal-time-util.c b/src/calendar/libecal/e-cal-time-util.c
index 914761c..22649c5 100644
--- a/src/calendar/libecal/e-cal-time-util.c
+++ b/src/calendar/libecal/e-cal-time-util.c
@@ -379,6 +379,7 @@ time_day_begin_with_zone (time_t time,
                           icaltimezone *zone)
 {
        struct icaltimetype tt;
+       time_t new_time;
 
        /* Convert to an icaltimetype. */
        tt = icaltime_from_timet_with_zone (time, FALSE, zone);
@@ -388,8 +389,12 @@ time_day_begin_with_zone (time_t time,
        tt.minute = 0;
        tt.second = 0;
 
-       /* Convert back to a time_t. */
-       return icaltime_as_timet_with_zone (tt, zone);
+       /* Convert back to a time_t and make sure the time is in the past. */
+       while (new_time = icaltime_as_timet_with_zone (tt, zone), new_time > time) {
+               icaltime_adjust (&tt, 0, -1, 0, 0);
+       }
+
+       return new_time;
 }
 
 /**
@@ -410,21 +415,24 @@ time_day_end_with_zone (time_t time,
                         icaltimezone *zone)
 {
        struct icaltimetype tt;
+       time_t new_time;
 
        /* Convert to an icaltimetype. */
        tt = icaltime_from_timet_with_zone (time, FALSE, zone);
 
        /* Set it to the start of the next day. */
-       tt.day++;
        tt.hour = 0;
        tt.minute = 0;
        tt.second = 0;
 
-       /* Normalize it, to fix any overflow. */
-       tt = icaltime_normalize (tt);
+       icaltime_adjust (&tt, 1, 0, 0, 0);
 
-       /* Convert back to a time_t. */
-       return icaltime_as_timet_with_zone (tt, zone);
+       /* Convert back to a time_t and make sure the time is in the future. */
+       while (new_time = icaltime_as_timet_with_zone (tt, zone), new_time <= time) {
+               icaltime_adjust (&tt, 0, 1, 0, 0);
+       }
+
+       return new_time;
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]