To find the timezone swaks will get the localtime() and gmtime() of the unix 
time (seconds since 1970-01-01 00:00:00 UTC), then use timelocal() to convert 
both of them back to unix time.  The problem is timelocal() does a daylight 
savings aware version of the conversion, so if you are in a +1000/+1100 
timezone then for a period of 11 hours after daylight savings starts the 
gmtime() function will return a time that's not in daylight savings time 
according to local time (as used by localtime() and timelocal()), so this will 
mess up the time zone calculations and make swaks put a bogus Date: header.

I've attached a program testdate.pl to demonstrate this.  Run it with a 
parameter that is just after the start or end of daylight savings in your time 
zone to demonstrate (not that the "RIGHT" version of the code in my test 
program agrees with the date command).  I will send a patch for swaks shortly.

etbe@liv:/tmp$ date -d "1970-01-01 1601778959 sec utc" -R
Sun, 04 Oct 2020 13:35:59 +1100
etbe@liv:/tmp$ /tmp/testdate.pl 1601778959
WRONG: Sun, 04 Oct 2020 13:35:59 +1000
RIGHT: Sun, 04 Oct 2020 13:35:59 +1100

I've also run the date -R command, my Perl code, and the swaks code on every 
3000 seconds for over a year.  My code gives the same result as date -R, 
here's the diff between my code/date -R and swaks for Australian Eastern 
Standard Time:

$ diff date.txt swaksdate.txt 
1,12c1,12
< Sun, 04 Oct 2020 04:06:22 +1100
< Sun, 04 Oct 2020 04:56:22 +1100
< Sun, 04 Oct 2020 05:46:22 +1100
< Sun, 04 Oct 2020 06:36:22 +1100
< Sun, 04 Oct 2020 07:26:22 +1100
< Sun, 04 Oct 2020 08:16:22 +1100
< Sun, 04 Oct 2020 09:06:22 +1100
< Sun, 04 Oct 2020 09:56:22 +1100
< Sun, 04 Oct 2020 10:46:22 +1100
< Sun, 04 Oct 2020 11:36:22 +1100
< Sun, 04 Oct 2020 12:26:22 +1100
< Sun, 04 Oct 2020 13:16:22 +1100
---
> Sun, 04 Oct 2020 04:06:22 +1000
> Sun, 04 Oct 2020 04:56:22 +1000
> Sun, 04 Oct 2020 05:46:22 +1000
> Sun, 04 Oct 2020 06:36:22 +1000
> Sun, 04 Oct 2020 07:26:22 +1000
> Sun, 04 Oct 2020 08:16:22 +1000
> Sun, 04 Oct 2020 09:06:22 +1000
> Sun, 04 Oct 2020 09:56:22 +1000
> Sun, 04 Oct 2020 10:46:22 +1000
> Sun, 04 Oct 2020 11:36:22 +1000
> Sun, 04 Oct 2020 12:26:22 +1000
> Sun, 04 Oct 2020 13:16:22 +1000
5243,5254c5243,5254
< Sun, 04 Apr 2021 03:26:22 +1000
< Sun, 04 Apr 2021 04:16:22 +1000
< Sun, 04 Apr 2021 05:06:22 +1000
< Sun, 04 Apr 2021 05:56:22 +1000
< Sun, 04 Apr 2021 06:46:22 +1000
< Sun, 04 Apr 2021 07:36:22 +1000
< Sun, 04 Apr 2021 08:26:22 +1000
< Sun, 04 Apr 2021 09:16:22 +1000
< Sun, 04 Apr 2021 10:06:22 +1000
< Sun, 04 Apr 2021 10:56:22 +1000
< Sun, 04 Apr 2021 11:46:22 +1000
< Sun, 04 Apr 2021 12:36:22 +1000
---
> Sun, 04 Apr 2021 03:26:22 +1100
> Sun, 04 Apr 2021 04:16:22 +1100
> Sun, 04 Apr 2021 05:06:22 +1100
> Sun, 04 Apr 2021 05:56:22 +1100
> Sun, 04 Apr 2021 06:46:22 +1100
> Sun, 04 Apr 2021 07:36:22 +1100
> Sun, 04 Apr 2021 08:26:22 +1100
> Sun, 04 Apr 2021 09:16:22 +1100
> Sun, 04 Apr 2021 10:06:22 +1100
> Sun, 04 Apr 2021 10:56:22 +1100
> Sun, 04 Apr 2021 11:46:22 +1100
> Sun, 04 Apr 2021 12:36:22 +1100
10483,10496c10483,10496
< Sun, 03 Oct 2021 03:06:22 +1100
< Sun, 03 Oct 2021 03:56:22 +1100
< Sun, 03 Oct 2021 04:46:22 +1100
< Sun, 03 Oct 2021 05:36:22 +1100
< Sun, 03 Oct 2021 06:26:22 +1100
< Sun, 03 Oct 2021 07:16:22 +1100
< Sun, 03 Oct 2021 08:06:22 +1100
< Sun, 03 Oct 2021 08:56:22 +1100
< Sun, 03 Oct 2021 09:46:22 +1100
< Sun, 03 Oct 2021 10:36:22 +1100
< Sun, 03 Oct 2021 11:26:22 +1100
< Sun, 03 Oct 2021 12:16:22 +1100
< Sun, 03 Oct 2021 13:06:22 +1100
< Sun, 03 Oct 2021 13:56:22 +1100
---
> Sun, 03 Oct 2021 03:06:22 +1000
> Sun, 03 Oct 2021 03:56:22 +1000
> Sun, 03 Oct 2021 04:46:22 +1000
> Sun, 03 Oct 2021 05:36:22 +1000
> Sun, 03 Oct 2021 06:26:22 +1000
> Sun, 03 Oct 2021 07:16:22 +1000
> Sun, 03 Oct 2021 08:06:22 +1000
> Sun, 03 Oct 2021 08:56:22 +1000
> Sun, 03 Oct 2021 09:46:22 +1000
> Sun, 03 Oct 2021 10:36:22 +1000
> Sun, 03 Oct 2021 11:26:22 +1000
> Sun, 03 Oct 2021 12:16:22 +1000
> Sun, 03 Oct 2021 13:06:22 +1000
> Sun, 03 Oct 2021 13:56:22 +1000

-- 
My Main Blog         http://etbe.coker.com.au/
My Documents Blog    http://doc.coker.com.au/

Attachment: testdate.pl
Description: Perl program

Reply via email to