[Freeipa-devel] timestamps
John Dennis
jdennis at redhat.com
Wed Jul 15 13:44:46 UTC 2009
Dmitri and I were discussing the storage of timestamps yesterday. My
understanding of best practice (after much investigation) is to store
timestamps in UTC paired with the current zoneinfo (important
clarification, *not* the local offset, rather the *zoneinfo* [1]). This
is the only unambiguous way be able to convert to/from local time in the
past, now, and in the future. It also has the nice property of
preserving the timestamp in a normalized form (UTC) which can be
compared to other timestamps and/or presented in another zone (in the
past, now, or in the future).
However one problem I encountered as I tried to implement this was I
could not find a standard library which returned the current zoneinfo.
glibc and other posix libraries provide offsets and/or the TZ value
(which really just an offset in wolf's clothing). I have a very clear
understanding of how to retrieve the zoneinfo in a Linux environment. In
fact I found a number of examples of code which had their own private
function to query the zoneinfo. The downside to this is it is OS
specific (but it's not too terrible to tweak it to a particular OS).
So I have a few questions:
* Jakob, in the policy engine when you wrote the code which deals with
time evaluation how did you handle the zone issue?
* Have others needed to deal with timestamps and if so what has been
your methodology?
* Is anyone aware of a library which can retrieve the zoneinfo in a
portable manner?
[1] If you're wondering why offsets are evil and why zoneinfo was
invented it's because timezones are notoriously fluid, they are the
result of political decisions and vary in unpredictable ways (in both
the geographic domain and the time domain). The only unambiguous way to
know what a proper offset is to know a geographic location at a specific
moment in history, hence the introduction of the zoneinfo database which
allows one to query the offset based on location and moment in time.
--
John Dennis <jdennis at redhat.com>
Looking to carve out IT costs?
www.redhat.com/carveoutcosts/
More information about the Freeipa-devel
mailing list