From f91b7cdee0efb7af2989eed56b6e3248da2b6712 Mon Sep 17 00:00:00 2001 From: Lars Henriksen Date: Tue, 30 Oct 2018 20:27:02 +0100 Subject: DST fix: adding appointments on the day when DST starts or stops A new apppoint inserted on the day when the clock is adjusted backward by an hour got a wrong start time (an hour late). Reason: mktime() must not use the Daylight Saving Time information returned by localtime_r(). Also editorial simplifications. Signed-off-by: Lukas Fleischer --- src/utils.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/utils.c b/src/utils.c index 4758e0f..09f1f98 100644 --- a/src/utils.c +++ b/src/utils.c @@ -530,24 +530,20 @@ long date_sec_change(long date, int delta_month, int delta_day) return t; } -/* - * Return a long containing the date which is updated taking into account - * the new time and date entered by the user. - */ -long update_time_in_date(long date, unsigned hr, unsigned mn) +/* A time in seconds is updated with new hour and minutes and returned. */ +time_t update_time_in_date(time_t date, unsigned hr, unsigned mn) { struct tm lt; - time_t t, new_date; - t = date; - localtime_r(&t, <); + localtime_r(&date, <); lt.tm_hour = hr; lt.tm_min = mn; lt.tm_sec = 0; - new_date = mktime(<); - EXIT_IF(new_date == -1, _("error in mktime")); + lt.tm_isdst = -1; + date = mktime(<); + EXIT_IF(date == -1, _("error in mktime")); - return new_date; + return date; } /* -- cgit v1.2.3-70-g09d2