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>
This commit is contained in:
Lars Henriksen 2018-10-30 20:27:02 +01:00 committed by Lukas Fleischer
parent efdff01da8
commit f91b7cdee0

View File

@ -530,24 +530,20 @@ long date_sec_change(long date, int delta_month, int delta_day)
return t; return t;
} }
/* /* A time in seconds is updated with new hour and minutes and returned. */
* Return a long containing the date which is updated taking into account time_t update_time_in_date(time_t date, unsigned hr, unsigned mn)
* the new time and date entered by the user.
*/
long update_time_in_date(long date, unsigned hr, unsigned mn)
{ {
struct tm lt; struct tm lt;
time_t t, new_date;
t = date; localtime_r(&date, &lt);
localtime_r(&t, &lt);
lt.tm_hour = hr; lt.tm_hour = hr;
lt.tm_min = mn; lt.tm_min = mn;
lt.tm_sec = 0; lt.tm_sec = 0;
new_date = mktime(&lt); lt.tm_isdst = -1;
EXIT_IF(new_date == -1, _("error in mktime")); date = mktime(&lt);
EXIT_IF(date == -1, _("error in mktime"));
return new_date; return date;
} }
/* /*