aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Henriksen <LarsHenriksen@get2net.dk>2018-10-30 20:27:02 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2018-11-10 12:19:28 +0100
commitf91b7cdee0efb7af2989eed56b6e3248da2b6712 (patch)
tree723677a3f401d5c855a53c96a7354acc9583eff9 /src
parentefdff01da87a4174c079d21a63df16af47401fa5 (diff)
downloadcalcurse-f91b7cdee0efb7af2989eed56b6e3248da2b6712.tar.gz
calcurse-f91b7cdee0efb7af2989eed56b6e3248da2b6712.zip
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 <lfleischer@calcurse.org>
Diffstat (limited to 'src')
-rw-r--r--src/utils.c18
1 files changed, 7 insertions, 11 deletions
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, &lt);
+ localtime_r(&date, &lt);
lt.tm_hour = hr;
lt.tm_min = mn;
lt.tm_sec = 0;
- new_date = mktime(&lt);
- EXIT_IF(new_date == -1, _("error in mktime"));
+ lt.tm_isdst = -1;
+ date = mktime(&lt);
+ EXIT_IF(date == -1, _("error in mktime"));
- return new_date;
+ return date;
}
/*