Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gets time wrong at the end of daylight savings #17

Closed
ametzler opened this issue Apr 25, 2020 · 1 comment
Closed

gets time wrong at the end of daylight savings #17

ametzler opened this issue Apr 25, 2020 · 1 comment

Comments

@ametzler
Copy link

Hello,

this is https://bugs.debian.org/955798 reported Russell Coker:

Swaks (oder the perl libraries it uses) does not get the start of DST right:

ametzler@argenau:~$ env LC_ALL=C TZ=Australia/Sydney faketime '2020-04-05 09:21:47'  date
Sun Apr  5 09:21:47 AEST 2020
ametzler@argenau:~$ env LC_ALL=C TZ=Australia/Sydney faketime '2020-04-05 09:21:47'  date +%z
+1000
ametzler@argenau:~$ env LC_ALL=C TZ=Australia/Sydney faketime '2020-04-05 12:59:58' swaks -s localhost -t [...]
[...]
 ~> Date: Sun, 05 Apr 2020 12:59:58 +1100
[...]
ametzler@argenau:~$ env LC_ALL=C TZ=Australia/Sydney faketime '2020-04-05 13:00:01' swaks -s localhost -t [...]
[...]
 ~> Date: Sun, 05 Apr 2020 13:00:01 +1000

The TZ offset in the date header jumps from +1100 to +1000 at about 13:00.

Russel describes the behavior as follows:
Before 13:00 Swaks is taking the current human readable time but applying the timezone offset from yesterday when daylight savings was running. [...] It seems that swaks (or maybe the Perl libraries it uses) was about 10 or 11 hours late in recognising the daylight savings change. Maybe it thought
that the early morning daylight savings time change meant early morning UTC not early morning in my timezone.

@jetmore
Copy link
Owner

jetmore commented Apr 25, 2020

This bug was actually a little stranger than reported. It actually got the DST change right once, then got it wrong for several hours:

for HOUR in `seq -w 0 23`
do
  env LC_ALL=C TZ=Australia/Sydney faketime "2020-04-05 $HOUR:30:00"  ../swaks -t foo --dump 2>&1 | grep Date:
done
Date: Sun, 05 Apr 2020 00:30:00 +1100
Date: Sun, 05 Apr 2020 01:30:00 +1100
Date: Sun, 05 Apr 2020 02:30:01 +1000   <------------
Date: Sun, 05 Apr 2020 03:30:00 +1100
Date: Sun, 05 Apr 2020 04:30:00 +1100
Date: Sun, 05 Apr 2020 05:30:00 +1100
Date: Sun, 05 Apr 2020 06:30:00 +1100
Date: Sun, 05 Apr 2020 07:30:00 +1100
Date: Sun, 05 Apr 2020 08:30:01 +1100
Date: Sun, 05 Apr 2020 09:30:00 +1100
Date: Sun, 05 Apr 2020 10:30:00 +1100
Date: Sun, 05 Apr 2020 11:30:00 +1100
Date: Sun, 05 Apr 2020 12:30:00 +1100
Date: Sun, 05 Apr 2020 13:30:00 +1000  <-------------
Date: Sun, 05 Apr 2020 14:30:01 +1000
Date: Sun, 05 Apr 2020 15:30:00 +1000
Date: Sun, 05 Apr 2020 16:30:00 +1000
Date: Sun, 05 Apr 2020 17:30:00 +1000
Date: Sun, 05 Apr 2020 18:30:00 +1000
Date: Sun, 05 Apr 2020 19:30:00 +1000
Date: Sun, 05 Apr 2020 20:30:01 +1000
Date: Sun, 05 Apr 2020 21:30:00 +1000
Date: Sun, 05 Apr 2020 22:30:00 +1000
Date: Sun, 05 Apr 2020 23:30:00 +1000

Unfortunately I'm pretty sure the issue is inside the Time::Local module or my use of it in a way I don't understand. Fortunately, 20 years later, I now recognize that my use of Time::Local was silly and I just replaced the whole thing with POSIX::strftime, which works a treat. Here's the new output:

for HOUR in `seq -w 0 23`
do
  env LC_ALL=C TZ=Australia/Sydney faketime "2020-04-05 $HOUR:30:00"  ../swaks -t foo --dump 2>&1 | grep Date:
done
Date: Sun, 05 Apr 2020 00:30:01 +1100
Date: Sun, 05 Apr 2020 01:30:00 +1100
Date: Sun, 05 Apr 2020 02:30:00 +1000
Date: Sun, 05 Apr 2020 03:30:00 +1000
Date: Sun, 05 Apr 2020 04:30:00 +1000
Date: Sun, 05 Apr 2020 05:30:00 +1000
Date: Sun, 05 Apr 2020 06:30:01 +1000
Date: Sun, 05 Apr 2020 07:30:00 +1000
Date: Sun, 05 Apr 2020 08:30:00 +1000
Date: Sun, 05 Apr 2020 09:30:00 +1000
Date: Sun, 05 Apr 2020 10:30:00 +1000
Date: Sun, 05 Apr 2020 11:30:01 +1000
Date: Sun, 05 Apr 2020 12:30:00 +1000
Date: Sun, 05 Apr 2020 13:30:00 +1000
Date: Sun, 05 Apr 2020 14:30:00 +1000
Date: Sun, 05 Apr 2020 15:30:00 +1000
Date: Sun, 05 Apr 2020 16:30:00 +1000
Date: Sun, 05 Apr 2020 17:30:01 +1000
Date: Sun, 05 Apr 2020 18:30:00 +1000
Date: Sun, 05 Apr 2020 19:30:00 +1000
Date: Sun, 05 Apr 2020 20:30:00 +1000
Date: Sun, 05 Apr 2020 21:30:00 +1000
Date: Sun, 05 Apr 2020 22:30:00 +1000
Date: Sun, 05 Apr 2020 23:30:01 +1000

jetmore added a commit that referenced this issue Oct 14, 2020
The issue was originally caused by 434f494, which was at attempt to fix timezone handling but mistakenly ended up localizing the text strings in the date, which was incorrect

Localizing the strings introduced characted issues for some locales that prevented the text from being rendered properly (specifically seen in cs_CZ.UTF-8) but only in some perls (did not happen in perl 5.18.4 (system) or 5.32.0 (brew) on macOS 10.15.6.  DID show up in perl 5.28.1 (system) on Debian 10.5.

If the fix for un-localizing the date had worked (3a95aa0), the character rendering issue also would have been fixed.  However, the fix worked on macOS and failed on Debian, the same as above.

So, this commit is a fix for #17 that doesn't incorrectly introduce localized dates, which in turn caused #25.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants