GNOME Bugzilla – Bug 521680
daylight savings problem with date:seconds()
Last modified: 2008-04-08 19:23:44 UTC
Please describe the problem: During daylight savings time and during the crossovers into and out of daylight savings, date:seconds() reports the incorrect value. Steps to reproduce: 1. Set your computer's clock to 2008-03-09 03:11:00 2. Run date:seconds and view the value: 1205050260 Actual results: the value of date:seconds is 1205050260 Expected results: the value of date:seconds should be 1205046660, as reported by: date +%s Does this happen every time? Other information:
Created attachment 107017 [details] test showing the incorrect behavior Use this script to test your version of xsltproc. It will change the clock on your machine! The only command line argument is a path to the xsltproc binary to test. Here is what the output should look like with the current code: testbed1:~/peter-testing # ./time-test ./xsltproc Shutting down network time protocol daemon (NTPD) done test 1 FAILURE: 1155661200 1155657600 (date was 2006-08-15 12:00:00) test 2a FAILURE: 1162101720 1162098120 (date was 2006-10-29 01:02:00) test 2b success: 1162105320 test 2c success: 1162108920 test 3 success: 1167411720 test 4a success: 1173586320 test 4b success: 1173592740 test 4c success: 1173595680 test 4c FAILURE: 1173600720 1173597120 (date was 2007-03-11 03:12:00) test 5 FAILURE: 1184126400 1184122800 (date was 2007-07-10 23:00:00) test 6a FAILURE: 1194156660 1194153060 (date was 2007-11-04 01:11:00) test 6b success: 1194167460 test 7 success: 1199437860 test 8a success: 1205039460 test 8b success: 1205043060 test 8c FAILURE: 1205050260 1205046660 (date was 2008-03-09 03:11:00) Starting network time protocol daemon (NTPD) done
Created attachment 107018 [details] [review] patch This patch fixes the problem. It calculates the timezone offset from GMT manually, by comparing each field between the local tm struct and the gm tm struct.
Okay, this looks sane, and makes sense, thanks a lot for the report and the patch, applied and commited to SVN, Daniel
Created attachment 108545 [details] [review] corrected patch Daniel -- oops, I forgot to attach an updated patch that fixes an error I made in the patch I had attached before. I didn't properly copy the time structures to handle non-reentrant versions of the time functions. This is the correct patch. Peter
Okay, I applied the corrected patch just before the 1.1.23 release, thanks, Daniel