File: test-timezone-support

package info (click to toggle)
remind 06.02.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 40,884 kB
  • sloc: ansic: 25,733; sh: 6,377; perl: 2,926; lisp: 431; makefile: 263
file content (271 lines) | stat: -rwxr-xr-x 8,593 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
#!/bin/sh
export LC_ALL=C.UTF-8
export LANG=C.UTF-8

DIR=`dirname $0`
cd $DIR
if test $? != 0 ; then
    echo ""
    echo "Unable to cd $DIR" >&2
    echo ""
    exit 1
fi

if test `id -u` = 0 ; then
    echo ""
    echo "*** Please do not run the test suite as root; it will fail."
    echo ""
    exit 1
fi

# Colorize output iff stdout is a tty
stty <&1 > /dev/null 2>&1
if test $? = 0; then
    RED=""
    GRN=""
    NRM=""
else
    RED=""
    GRN=""
    NRM=""
fi

# We alias "remind" here so that we don't inadvertently add code that
# runs the system-installed verion of Remind rather than
# ../src/remind.  This trick was suggested by Jochen Sprickerhof
alias remind="echo You should be using ../src/remind explicitly in test-rem >&2; exit 1"

REMIND="../src/remind -h -q --flush"
OUT=../tests/tz.out
CMP=../tests/tz.cmp

echo "Running timezone tests"
cp /dev/null $OUT

TZ=Europe/Amsterdam $REMIND - 2025-09-03@14:00 <<'EOF' >> $OUT 2>&1
SET $AddBlankLines=0
BANNER %
REM Fri AT 23:30 TZ America/Toronto +1000 SATISFY [$Td == 13] MSG Fri 13th @23:30 Eastern is %a %2 here
DEBUG +x
SET a $T
SET b $Tt
SET c trigtz()
SET d trigtime()
SET e trigtimetz()
SET f trigeventstart()
SET g trigeventstarttz()
DEBUG -x
EOF

TZ=Europe/Amsterdam $REMIND - 2026-02-14@14:00 <<'EOF' >> $OUT 2>&1
SET $AddBlankLines=0
BANNER %
REM Fri AT 23:30 TZ America/Toronto +1000 SATISFY [$Td == 13] MSG Fri 13th @23:30 Eastern is %a %2 here
DEBUG +x
SET a $T
SET b $Tt
SET c trigtz()
SET d trigtime()
SET e trigtimetz()
SET f trigeventstart()
SET g trigeventstarttz()
DEBUG -x
EOF

TZ=Europe/Amsterdam $REMIND - 2026-02-15@14:00 <<'EOF' >> $OUT 2>&1
SET $AddBlankLines=0
BANNER %
REM Fri AT 23:30 TZ America/Toronto +1000 SATISFY [$Td == 13] MSG Fri 13th @23:30 Eastern is %a %2 here
SET a $T
SET b $Tt
SET c trigtz()
SET d trigtime()
SET e trigtimetz()
SET f trigeventstart()
SET g trigeventstarttz()
EOF

TZ=America/Toronto $REMIND -p12 - 2025-01-01 <<'EOF' 2>&1 | grep Locally >> $OUT 2>&1
REM Second Thursday AT 15:00 TZ Europe/Amsterdam MSG Locally: %3
EOF

TZ=America/Toronto $REMIND -g - 2026-01-01 <<'EOF' >> $OUT 2>&1
BANNER %
SET $AddBlankLines 0
SET new   '2026-01-18@14:53'
SET first '2026-01-25@23:48'
SET full  '2026-01-03@05:04'
SET last  '2026-01-10@10:49'

REM [new]   +100 MSG New Moon      %*l %3.

SET a trigtz()
SET b trigtime()
SET c trigtimetz()
SET d trigeventstart()
SET e trigeventstarttz()

REM MSG trigtz = [a], trigtime = [b], trigtimetz = [c], trigeventstart = [d], trigeventstarttz = [e]

REM [first] +100 MSG First Quarter %*l %3.
REM [full]  +100 MSG Full Moon     %*l %3.
REM [last]  +100 MSG Last Quarter  %*l %3.

SET new   tzconvert(new,   "America/Toronto", "Australia/Sydney")
SET first tzconvert(first, "America/Toronto", "Australia/Sydney")
SET full  tzconvert(full,  "America/Toronto", "Australia/Sydney")
SET last  tzconvert(last,  "America/Toronto", "Australia/Sydney")

REM [new]   +100 TZ Australia/Sydney MSG New Moon      %*l %3. (*)

SET a trigtz()
SET b trigtime()
SET c trigtimetz()
SET d trigeventstart()
SET e trigeventstarttz()

REM MSG trigtz = [a], trigtime = [b], trigtimetz = [c], trigeventstart = [d], trigeventstarttz = [e]

REM [first] +100 TZ Australia/Sydney MSG First Quarter %*l %3. (*)
REM [full]  +100 TZ Australia/Sydney MSG Full Moon     %*l %3. (*)
REM [last]  +100 TZ Australia/Sydney MSG Last Quarter  %*l %3. (*)

REM MSG new=[new] first=[first] full=[full] last=[last]

EOF

TZ=America/Los_Angeles $REMIND - 2026-01-01 <<'EOF' >> $OUT 2>&1
BANNER %
SET $AddBlankLines 0

REM AT 13:33 MSG Whatsup? %*l %3.
REM AT 13:33 TZ "" MSG Whatsup? %*l %3.
EOF

TZ=America/Los_Angeles $REMIND - 2026-01-01 <<'EOF' >> $OUT 2>&1
BANNER %
SET $AddBlankLines 0

REM AT 13:33 TZ America/Los_Angeles TZ UTC MSG Whatsup? %*l %3.
REM AT 13:33 TZ "" TZ America/Los_Angeles MSG Whatsup? %*l %3.
REM TZ UTC MSG Borked
EOF

TZ=America/Toronto $REMIND -dx - 2025-09-01@01:00 <<'EOF' >> $OUT 2>&1
SET a tzconvert('2025-09-01@14:44', "", "Europe/Berlin")
SET a tzconvert('2025-09-01@14:44', "America/Toronto", "Europe/Berlin")
SET a tzconvert('2025-09-01@14:44', "Europe/Berlin", "")
SET a tzconvert('2025-09-01@14:44', "Europe/Berlin")
SET a tzconvert('2025-09-01@14:44', "", "")
SET a tzconvert('2025-09-01@14:44', "")

SET b evaltrig("Wednesday at 23:00 TZ Australia/Sydney")
SET b evaltrig("Wednesday at 23:00 TZ Europe/Amsterdam")
SET b evaltrig("Wednesday at 23:00 TZ America/Los_Angeles")
set b evaltrig("Wednesday TZ Europe/Amsterdam")

debug +t
set c trig("Mon at 00:00 TZ Australia/Sydney",\
           "Tue at 00:00 TZ America/Toronto",\
           "Wed at 00:00 TZ Europe/Amsterdam",\
           "Thu at 00:00 TZ America/Los_Angeles",\
           "Fri at 00:00 TZ Australia/Sydney",\
           "Sat at 00:00 TZ Australia/Sydney",\
           "Sun at 00:00 TZ Australia/Sydney", \
           "at 14:42")
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

echo "" >> $OUT
# Bug reported by Jin Chen
TZ=Australia/Sydney $REMIND -s - 2025-10-01 <<'EOF' >> $OUT 2>&1
REM Wednesday AT 14:00 TZ America/Toronto MSG 2PM Eastern
EOF

echo "" >> $OUT
# And the inverse...
TZ=America/Toronto $REMIND -s - 2025-10-01 <<'EOF' >> $OUT 2>&1
REM Wednesday AT 14:00 TZ Australia/Sydney MSG 2PM Sydney
EOF

echo "" >> $OUT
# Every day and a SATISFY reminder
TZ=America/Toronto $REMIND -s - 2025-10-01 <<'EOF' >> $OUT 2>&1
REM AT 04:44 TZ America/Los_Angeles MSG 04:44 every day in L.A.
REM 2 AT 05:00 TZ America/Los_Angeles MSG 05:00 on 2nd in L.A.
REM Wed AT 06:00 TZ America/Los_Angeles MSG 06:00 on Wed in L.A.
REM Wed AT 23:00 TZ America/Los_Angeles MSG 23:00 on Wed in L.A.
REM AT 09:00 TZ America/Los_Angeles SATISFY [!($Td % 3)] MSG 09:00 every third day in L.A.
REM AT 22:00 TZ America/Los_Angeles SATISFY [!($Td % 3)] MSG 22:00 every third day in L.A.
EOF

echo "" >> $OUT
# And the inverse
TZ=America/Los_Angeles $REMIND -s - 2025-10-01 <<'EOF' >> $OUT 2>&1
REM AT 04:44 TZ America/Toronto MSG 04:44 every day in T.O.
REM 2 AT 05:00 TZ America/Toronto MSG 05:00 on 2nd in T.O.
REM Wed AT 06:00 TZ America/Toronto MSG 06:00 on Wed in T.O.
REM Wed AT 01:00 TZ America/Toronto MSG 01:00 on Wed in T.O.
REM AT 09:00 TZ America/Toronto SATISFY [!($Td % 3)] MSG 09:00 every third day in T.O.
REM AT 02:00 TZ America/Toronto SATISFY [!($Td % 3)] MSG 02:00 every third day in T.O.
EOF

# Semi-exhaustive checking...
OFFSETS="-12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12"
cat <<'EOF' >> $OUT

NOTE NOTE NOTE: The notation UTC+n denotes a time zone n hours
WEST of UTC, and UTC-n denotes a time zone n hours EAST of
UTC... the opposite of what you might think.  The zone
UTC+1 is two hours EARLIER than UTC-1.

EOF

for src in $OFFSETS; do
    srczone="UTC$src"
    for dst in $OFFSETS ; do
        dstzone="UTC$dst"
        (echo 'BANNER %'; echo "REM AT 00:00 TZ !$dstzone MSG 00:00 at $dstzone in [getenv(\"TZ\")] is %3, %r %m; diff=[(\$Tt-00:00)/60]") | TZ=$srczone $REMIND '-i$addblanklines=0' - 2025-10-09@12:00 >> $OUT 2>&1
    done
done
for src in $OFFSETS; do
    srczone="UTC$src"
    for dst in $OFFSETS ; do
        dstzone="UTC$dst"
        (echo 'BANNER %'; echo "REM AT 12:00 TZ !$dstzone MSG 12:00 at $dstzone in [getenv(\"TZ\")] is %3, %r %m; diff=[(\$Tt-12:00)/60]") | TZ=$srczone $REMIND '-i$addblanklines=0' - 2025-10-09@12:00 >> $OUT 2>&1
    done
done
for src in $OFFSETS; do
    srczone="UTC$src"
    for dst in $OFFSETS ; do
        dstzone="UTC$dst"
        (echo 'BANNER %'; echo "REM 11 ++10 AT 00:00 TZ !$dstzone MSG 00:00 on 11th at $dstzone in [getenv(\"TZ\")] is %3, %r %m; diff=[(trigdatetime()-'2025-10-11@00:00')/60]") | TZ=$srczone $REMIND '-i$addblanklines=0' - 2025-10-09@12:00 >> $OUT 2>&1
    done
done
for src in $OFFSETS; do
    srczone="UTC$src"
    for dst in $OFFSETS ; do
        dstzone="UTC$dst"
        (echo 'BANNER %'; echo "REM 11 ++10 AT 12:00 TZ !$dstzone MSG 12:00 on 11th at $dstzone in [getenv(\"TZ\")] is %3, %r %m; diff=[(trigdatetime()-'2025-10-11@12:00')/60]") | TZ=$srczone $REMIND '-i$addblanklines=0' - 2025-10-09@12:00 >> $OUT 2>&1
    done
done

cmp -s $OUT $CMP
if [ "$?" = "0" ] ; then
    echo "Remind:   Time zone tests ${GRN}PASSED${NRM}"
    exit 0
else
    echo "Remind:   Time zone tests ${RED}FAILED${NRM}"
    echo "Examine the file tz.out to see where it differs from the"
    echo "reference file tz.cmp.  Here are the first 200 lines of"
    echo "diff -u tz.out tz.cmp"
    echo ""
    diff -u $OUT $CMP | head -n 200
    echo ""
    exit 1
fi