aboutsummaryrefslogtreecommitdiffstats
path: root/src/calcurse.h
diff options
context:
space:
mode:
authorLars Henriksen <LarsHenriksen@get2net.dk>2018-10-30 19:53:55 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2018-11-10 12:19:28 +0100
commite6cffdc6bd58e0ddefbb0b21e8bbe841963bce48 (patch)
tree68855a9ab9bd9daae131588ba24b85fe24658aac /src/calcurse.h
parent4263a2850431b7328699c713b4e97667f9ba02e2 (diff)
downloadcalcurse-e6cffdc6bd58e0ddefbb0b21e8bbe841963bce48.tar.gz
calcurse-e6cffdc6bd58e0ddefbb0b21e8bbe841963bce48.zip
DST fix: daylength v. DAYINSEC
The number of seconds in a day and daylength in seconds differ when Daylight Saving Time is in effect on two days of the year. The day when DST takes effect is 23 hours long, and the day when DST ends is 25 hours long. In the latter case the date changing thread wóuld enter a loop in the last hour before midnight (in the former it would set the date an hour too late). The next midnight is calculated through mktime(), invoked by date2sec(). Wrong daylength prevented appointments from being stored in the day vector and caused them to be displayed wrongly in the appts panel. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/calcurse.h')
-rw-r--r--src/calcurse.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index fb20da7..616d954 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -144,7 +144,13 @@
#define WEEKINMIN (WEEKINHOURS * HOURINMIN)
#define WEEKINSEC (WEEKINMIN * MININSEC)
#define DAYINMIN (DAYINHOURS * HOURINMIN)
+/*
+ * Note the difference between the number of seconds in a day and daylength
+ * in seconds. The two may differ when DST is in effect (daylength is either
+ * 23, 24 or 25 hours. The argument to DAYLEN is of type time_t.
+ */
#define DAYINSEC (DAYINMIN * MININSEC)
+#define DAYLEN(date) (date_sec_change((date), 0, 1) - (date))
#define HOURINSEC (HOURINMIN * MININSEC)
#define MAXDAYSPERMONTH 31