Summary

timezone fixes

Metadata

Attachments

Description

In C_decode_seconds, on platforms that do not consult tm_gmtoff (currently everything other than OS X), the local timezone offset is always reported in the 10-element time vector. It should report the offset from UTC (0). The attached patch does that.

This change preserves the "UTC-ness" of the time object so that, if a user accepts 10-element time values in his own eggs, he can know the actual timezone offset without external help. I'd like to use this fixed behavior in a egg I am working on.

I think syn is having a somewhat related issue with DST, which we will tackle in another ticket.

Changes and comments

[2010-07-19 19:29:56 UTC] zbigniew attached 0001-C_decode_seconds-should-report-zero-timezone-offset-.patch (description=#f)

[2010-07-20 01:52:36 UTC] felix changed status from new to accepted

[2010-07-20 01:52:36 UTC] felix set owner to felix

[2010-07-20 02:43:22 UTC] zbigniew wrote:

Hold off from applying for a couple hours, I have two other small patches to add which totally fix Moritz's problem. Or I can open another ticket.

[2010-07-20 03:36:10 UTC] zbigniew attached 0002-Use-tm_gmtoff-for-all-GNU-environment-platforms-Linu.patch (description=#f)

[2010-07-20 03:36:20 UTC] zbigniew attached 0003-Correct-polarity-on-gmtoff-to-tmvec-conversions-fixe.patch (description=#f)

[2010-07-20 03:51:12 UTC] zbigniew changed summary

[2010-07-20 03:51:12 UTC] zbigniew wrote:

Patch 0002 changes seconds->local-time to use tm_gmtoff for all platforms that support it, not just OS X. As this is a BSD extension (present since BSD4.3-Reno) it is widely available. Currently we just use the local timezone, which is incorrect when calculating a time with DST not equal to current time (or if, say, timezone rules changed in the past). For example, on my machine, the second timezone offset should be 21600, because DST is in effect:

 (seconds->local-time 0) ;=> #(0 0 19 31 11 69 3 364 #f 18000)
 (seconds->local-time) ;=> #(48 45 21 19 6 110 1 199 #t 18000)

(Note that the timezone offset is always inclusive of DST and the dst flag is just advisory.

This does not fix the issue on Windows or some other platforms, but that would require more hacks, so I am punting on that.

[2010-07-20 04:09:01 UTC] zbigniew wrote:

Patch 0003 fixes an oversight in the polarity of tm_gmtoff when a struct tm is being copied in and out of a vector. tm_gmtoff is seconds east of UTC, while our 10-element vector holds seconds west of UTC. This is already handled in C_decode_seconds but not in the generic vector copy code.

 (time->string (seconds->local-time) "%z")   ;=> "+0500"         ; before patch
 (time->string (seconds->local-time) "%z")   ;=> "-0500"         ; after

strftime handling of %Z and %z is actually pretty iffy regardless; typically %Z will ignore the timezone offset you provide and just use your local timezone, and %z doesn't even correct for DST on OS X. There's nothing we can do about this. However, I fixed the bug anyway because it is a genuine issue in tm_gmtoff handling.

[2010-07-20 04:21:58 UTC] zbigniew wrote:

OK, I should be done. If there are any other issues let me know.

[2010-07-26 10:31:15 UTC] felix changed status from accepted to closed

[2010-07-26 10:31:15 UTC] felix set resolution to fixed

[2010-07-26 10:31:15 UTC] felix wrote:

Patches applied in "experimental" branch.

[2011-04-04 08:31:00 UTC] felix removed milestone 4.6.0

[2011-04-04 08:31:00 UTC] felix wrote:

Milestone 4.6.0 deleted