Allow empty string to be used in tzconvert to designate system default time zone.

This commit is contained in:
Dianne Skoll
2025-09-04 10:09:46 -04:00
parent faf8947dda
commit 4237dc4a3f
4 changed files with 27 additions and 6 deletions

View File

@@ -4928,11 +4928,13 @@ command can never be triggered:
Returns "STRING", "INT", "DATE", "TIME" or "DATETIME", depending on the type of \fIarg\fR.
.TP
.B tzconvert(q_datetime, s_srczone [,s_dstzone])
Converts \fBdatetime\fR from the time zone named by \fBsrczone\fR to the
time zone named by \fBdstzone\fR. If \fBdstzone\fR is omitted, the
default system time zone is used. The return value is a DATETIME. Time
zone names are system-dependent; consult your operating system for legal
values. Here is an example:
Converts \fBdatetime\fR from the time zone named by \fBsrczone\fR to
the time zone named by \fBdstzone\fR. If \fBsrczone\fR is the empty
string, then the default system time zone is used as the source zone.
If \fBdstzone\fR is omitted or is the empty string, the default system
time zone is used as the destination zone. The return value is a
DATETIME. Time zone names are system-dependent; consult your
operating system for legal values. Here is an example:
.PP
.nf
tzconvert('2007-07-08@01:14', "Canada/Eastern", "Canada/Pacific")

View File

@@ -3928,9 +3928,12 @@ int tz_convert(int year, int month, int day,
old_tz = StrDup(old_tz);
if (!old_tz) return E_NO_MEM;
}
if (tgt_tz == NULL) {
if (tgt_tz == NULL || !*tgt_tz) {
tgt_tz = old_tz;
}
if (src_tz == NULL || !*src_tz) {
src_tz = old_tz;
}
/* set source TZ */
r = tz_set_tz(src_tz);

View File

@@ -101,6 +101,15 @@ REM AT 13:33 TZ "" TZ America/Los_Angeles MSG Whatsup? %*l %3.
REM TZ Universal MSG Borked
EOF
TZ=America/Toronto $REMIND -dx - <<'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', "")
EOF
cmp -s $OUT $CMP
if [ "$?" = "0" ] ; then
echo "Remind: Time zone test PASSED"

View File

@@ -31,3 +31,10 @@ Whatsup? today at 13:33.
-stdin-(5): TZ specified twice
-stdin-(6): TZ specified for non-timed reminder
No reminders.
tzconvert(2025-09-01@14:44, "", "Europe/Berlin") => 2025-09-01@20:44
tzconvert(2025-09-01@14:44, "America/Toronto", "Europe/Berlin") => 2025-09-01@20:44
tzconvert(2025-09-01@14:44, "Europe/Berlin", "") => 2025-09-01@08:44
tzconvert(2025-09-01@14:44, "Europe/Berlin") => 2025-09-01@08:44
tzconvert(2025-09-01@14:44, "", "") => 2025-09-01@14:44
tzconvert(2025-09-01@14:44, "") => 2025-09-01@14:44
No reminders.