[nail-devel] Hi - tzdata issue noted, patch included
Brought to you by:
gritter
|
From: Mason L. B. <ma...@bl...> - 2026-08-05 20:59:59
|
Hi there. I've identified (via a work situation) that there are problems
with how mailx does timezone calculations. In this instance, Vancouver made
a change, and will be on DST fulltime. Normally at the start of November
they'd revert to standard time from DST, but now their standard time is
unchanging. Despite this change not yet taking effect, mailx derives the
wrong timezone with tzdata-2026b and newer.
I'd thought the issue was in tzdata itself, and I'm not convinced there's
not an issue there, but there's some compelling argument that the way mailx
is doing it is out of data, error-prone, and generally incorrect.
There's some background in the Debian bug I opened, as the issue was
reproducable there with code exerpted from mailx:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1143499
The glibc folks decided things were working as intended:
https://sourceware.org/bugzilla/show_bug.cgi?id=34480
The most compelling argument that mailx needs to change is here:
https://lists.iana.org/hyperkitty/list/tz...@ia.../message/5IE3H2HFQNN2N67JBCHSBQM664PDVHYJ/
From that:
There's a simple fix for that code. Don't use mktime(gmtime()) trick.
It's attempting to discover the UT offset for a given time_t value. But
that's easy: just call localtime and look at tm_gmtoff. Problem solved.
And this approach is standardized (finally!) in POSIX.1-2024.
So I made up a patch that does that, and built a test package of
heirloom-mailx for RHEL. It appears to work correctly with the new zone.
The patch is attached. I can open a bug if there's a tracker and/or way to
submit a PR.
Here's an inline copy, since it's short:
$ cat mailx-sendout-tzdiff.patch
diff -ru a/sendout.c b/sendout.c
--- a/sendout.c 2026-08-05 13:23:23.746830743 -0700
+++ b/sendout.c 2026-08-05 13:24:26.180943233 -0700
@@ -1149,13 +1149,11 @@
int tzdiff, tzdiff_hour, tzdiff_min;
time(&t);
- tzdiff = t - mktime(gmtime(&t));
+ tmptr = localtime(&t);
+ tzdiff = tmptr->tm_gmtoff;
tzdiff_hour = (int)(tzdiff / 60);
tzdiff_min = tzdiff_hour % 60;
tzdiff_hour /= 60;
- tmptr = localtime(&t);
- if (tmptr->tm_isdst > 0)
- tzdiff_hour++;
return fprintf(fo, "%s: %s, %02d %s %04d %02d:%02d:%02d %+05d\n",
field,
weekday_names[tmptr->tm_wday],
--
Mason Loring Bliss (( "In the drowsy dark cave of the mind dreams
ma...@bl... )) build their nest with fragments dropped
http://blisses.org/ (( from day's caravan." - Rabindranath Tagore
|