diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-11-19 23:30:02 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-11-19 23:30:02 -0800 |
commit | 3155f9903ec263d33f375c762a6a346bc8dc92c5 (patch) | |
tree | d2fbec03a7df87436db24fe974887500b3ea22a8 /socket.c | |
parent | ad068f27d819465c78c574019f32a2e1d30ca5ff (diff) | |
download | txr-3155f9903ec263d33f375c762a6a346bc8dc92c5.tar.gz txr-3155f9903ec263d33f375c762a6a346bc8dc92c5.tar.bz2 txr-3155f9903ec263d33f375c762a6a346bc8dc92c5.zip |
time: bug: must subtract gmtoff, not add.
This works fine:
1> (time-struct-utc 0)
#S(time year 1970 month 1 day 1 hour 0 min 0 sec 0 wday 4 yday 0
dst nil gmtoff 0 zone "GMT")
2> *1.(time-utc)
0
3> *1.(time-local)
28800
But we want the following to return the same results:
1> (time-struct-local 0)
#S(time year 1969 month 12 day 31 hour 16 min 0 sec 0 wday 3 yday 364
dst nil gmtoff -28800 zone "PST")
2> *1.(time-utc)
-57600
3> *1.(time-local)
-28800
With the patch, we do:
1> (time-struct-local 0)
#S(time year 1969 month 12 day 31 hour 16 min 0 sec 0 wday 3 yday 364
dst nil gmtoff -28800 zone "PST")
2> *1.(time-utc)
0
3> *1.(time-local)
28800
This is also broken:
1> (time-parse-utc "%H:%M:%z" "00:00:-0800")
-28800
It must return 28800.
* time.c (time_meth): This function, which is the
imlpementation of the time-utc and time-local methods, must
subtract the gmtoff field, not add it. This is so that
a UTC time expressed in a local time zone will convert
back to the correct UTC epoch.
(time_parse_local, time_parse_utc): Here we likewise
must subtract the gmtoff.
Diffstat (limited to 'socket.c')
0 files changed, 0 insertions, 0 deletions