Force year-folding on 32-bit time_t machines.

This commit is contained in:
Dianne Skoll
2025-05-08 12:10:15 -04:00
parent bc8ce3e2cc
commit 4590e746c5
4 changed files with 33 additions and 1 deletions

View File

@@ -1581,7 +1581,7 @@ int CalcMinsFromUTC(int dse, int tim, int *mins, int *isdst)
/* If the year is greater than 2037, some Unix machines have problems.
Fold it back to a "similar" year and trust that the UTC calculations
are still valid... */
if (FoldYear && yr>2037) {
if (yr > 2037 && (FoldYear || (sizeof(time_t) < (64/CHAR_BIT)))) {
dse = DSE(yr, 0, 1);
yr = FoldArray[IsLeapYear(yr)][dse%7];
}

View File

@@ -722,6 +722,9 @@ SET $DefaultColor "255 0 0"
REM Wed MSG Wookie
EOF
# Test year-folding
TZ=America/Toronto ../src/remind -dx ../tests/yearfold.rem >> ../tests/test.out 2>&1
# Make sure all the include files are ok
find ../include -type f -name '*.rem' | while read x; do ../src/remind -n $x 1 Jan 2024 2>>../tests/test.out 1>/dev/null; done

View File

@@ -38257,3 +38257,12 @@ $Sunday is Duminică
2024/02/14 COLOR * * * 255 0 0 Wookie
2024/02/21 COLOR * * * 255 0 0 Wookie
2024/02/28 COLOR * * * 255 0 0 Wookie
trigger(2038-12-31@14:00, 1) => "31 December 2038 AT 09:00"
trigger(2038-12-31@14:00, 1) => "31 December 2038 AT 09:00"
trigger(2040-02-18@00:00, 1) => "17 February 2040 AT 19:00"
trigger(2040-02-18@00:00, 1) => "17 February 2040 AT 19:00"
trigger(2050-05-26@12:33, 1) => "26 May 2050 AT 08:33"
trigger(2050-05-26@12:33, 1) => "26 May 2050 AT 08:33"
trigger(2060-08-01@23:55, 1) => "1 August 2060 AT 19:55"
trigger(2060-08-01@23:55, 1) => "1 August 2060 AT 19:55"
No reminders.

20
tests/yearfold.rem Normal file
View File

@@ -0,0 +1,20 @@
BANNER %
SET $FoldYear 0
set a trigger('2038-12-31@14:00', 1)
SET $FoldYear 1
set a trigger('2038-12-31@14:00', 1)
SET $FoldYear 0
set a trigger('2040-02-18@00:00', 1)
SET $FoldYear 1
set a trigger('2040-02-18@00:00', 1)
SET $FoldYear 0
set a trigger('2050-05-26@12:33', 1)
SET $FoldYear 1
set a trigger('2050-05-26@12:33', 1)
SET $FoldYear 0
set a trigger('2060-08-01@23:55', 1)
SET $FoldYear 1
set a trigger('2060-08-01@23:55', 1)