[local-time-devel] ENCODE-TIMESTAMP with a timezone
Thomas Munro
munro at ip9.org
Thu May 14 14:35:13 UTC 2009
2009/5/14 Daniel Lowe <dlowe at bitmuse.com>:
> Your patch is guessing, using the UTC timestamp to attempt to find a working
> timezone. The problem is that more than one offset may be valid, given a local
> time. Yours simply picks the first it finds. It's equivalent to:
>
> (let ((offset (timestamp-subtimezone (encode-timestamp nsec sec minute hour
> day month year
> :offset 0)
> timezone)))
> (encode-timestamp nsec sec minute hour day month year :offset offset))
Not quite -- it isn't using UTC to guess the timestamp (unless UTC is
one of your subzones as it happens to be for London). It is doing the
following, using 2009-12-25 12:00 America/New_York as the example (to
avoid confusion about the use of GMT/UTC in London):
Examine the available subtimezones for America/New_York, then:
1. Try to interpret the time as 2009-12-25 12:00 EST (subzone 0);
does that map to a point in time when EST was valid?
2. Try to interpret the time as 2009-12-25 12:00 EDT (subzone 1);
does that map to a point in time when EDT was valid?
> I don't have any problems with guessing the offset - I just want to make
> explicit when a guess is being made, and that's most easily done by not
> providing a default offset at all.
>
> Come to think of it, it'd be pretty cool for :offset in encode-timestamp to
> optionally take a string, referring to the subtimezone.
But that would not be different in effect from using the offset as a
number - EDT and EST are just 'nicknames' for offsets, and if you
already know which one applies at the time you're encoding then you
don't need the functionality that I am attempting to propose.
More information about the local-time-devel
mailing list