[local-time-devel] ENCODE-TIMESTAMP with a timezone
Daniel Lowe
dlowe at bitmuse.com
Thu May 14 13:59:14 UTC 2009
Thomas Munro wrote:
> Isn't there a chicken and egg problem here? Given elements of a local
> time and a timezone, I can't make a timestamp because I don't have the
> offset, and you're saying that to get the correct offset I need the
> timestamp first.
You don't have to pass in the timestamp you're trying to create. A timezone is
really just a locale setting, and the offsets are stored in sub-timezones under
a given timezone. As I said before, if you could look up the sub-timezone by
name, you'd be able to identify the offset you desired. I'll make a patch for
that functionality sometime this week (unless someone else writes it).
> That is what my patch attempted to provide: you do not need to
> guess/provide the offset (unless you want to)
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))
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.
: Daniel :
More information about the local-time-devel
mailing list