mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Don't loop forever if a reminder moves backwards because of a time zone difference.
If we are not making progress, it's because the reminder has expired.
This commit is contained in:
@@ -554,6 +554,7 @@ int ComputeTriggerNoAdjustDuration(int today, Trigger *trig, TimeTrig const *tim
|
||||
y, m, d, omit,
|
||||
result;
|
||||
|
||||
int save_nextstart = 0;
|
||||
trig->expired = 0;
|
||||
if (save_in_globals) {
|
||||
LastTrigValid = 0;
|
||||
@@ -617,14 +618,24 @@ int ComputeTriggerNoAdjustDuration(int today, Trigger *trig, TimeTrig const *tim
|
||||
|
||||
/** FIXME: If a timed reminder moves to yesterday because of a time
|
||||
zone adjustment, try again! */
|
||||
|
||||
if (trig->tz) {
|
||||
TimeTrig copy = *tim;
|
||||
int new_result;
|
||||
ExitTimezone(trig->tz);
|
||||
new_result = AdjustTriggerForTimeZone(trig, result, ©);
|
||||
EnterTimezone(trig->tz);
|
||||
if (new_result + duration_days < today) {
|
||||
if (result + duration_days >= today &&
|
||||
new_result + duration_days < today) {
|
||||
/* If we are not making progress, then give up: It's expired */
|
||||
if (nextstart <= save_nextstart) {
|
||||
trig->expired = 1;
|
||||
if (DebugFlag & DB_PRTTRIG) {
|
||||
fprintf(ErrFp, "%s(%s): %s\n",
|
||||
GetCurrentFilename(), line_range(LineNoStart, LineNo), GetErr(E_EXPIRED));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
save_nextstart = nextstart;
|
||||
nextstart = start+1;
|
||||
start = nextstart;
|
||||
continue;
|
||||
|
||||
@@ -161,6 +161,9 @@ debug -t
|
||||
|
||||
EOF
|
||||
|
||||
TZ=America/Toronto $REMIND -s - 2025-09-01@00:00 <<'EOF' >> $OUT 2>&1
|
||||
REM 2025-09-24 AT 09:00 TZ America/Denver MSG Dr. Smith
|
||||
EOF
|
||||
cmp -s $OUT $CMP
|
||||
if [ "$?" = "0" ] ; then
|
||||
echo "Remind: Time zone test PASSED"
|
||||
|
||||
@@ -78,3 +78,4 @@ trig("Mon at 00:00 TZ Australia/Sydney", "Tue at 00:00 TZ America/Toronto", "Wed
|
||||
-stdin-(14:21): Trig(tz_adj Australia/Sydney) = Saturday, 6 September, 2025 AT 10:00
|
||||
-stdin-(14:21): Trig = Monday, 1 September, 2025 AT 14:42
|
||||
2025-09-01
|
||||
2025/09/24 * * * 660 11:00am Dr. Smith
|
||||
|
||||
Reference in New Issue
Block a user