Time zone confusion and implementation hints

Stephen Moir stephen.moir at quietagent.com
Thu Jul 1 20:45:12 UTC 2010

If you're looking at porting to Java at some stage, you might want to
consider using noda-time: http://code.google.com/p/noda-time/
<http://code.google.com/p/noda-time/>which is itself a port of joda-time (
http://joda-time.sourceforge.net/), both of which use the TZ database as
their base.

On 2 July 2010 08:29, Thomas KIPP <trwk76 at gmail.com> wrote:

> Hi Yves,
> There was an effort made a couple of years ago on CodePlex, implementing
> the TZDatabase.
> Here's the link: http://publicdomain.codeplex.com/
> Regards,
> Tom
> On Thu, Jul 1, 2010 at 9:22 PM, Yves Goergen <nospam.list at unclassified.de>wrote:
>> Hi,
>> I'm currently implementing an API for the tz database that should look
>> like .NET's TimeZoneInfo class to replace that in my application. The
>> API includes:
>> * Convert a date and time from UTC to a time zone
>> * Convert a date and time from a time zone to UTC
>> * Return the base UTC offset of a time zone for a date and time
>> * Return the save offset of a time zone for a date and time
>> * Determine whether a date and time is ambiguous in a time zone
>> * Determine whether a date and time is invalid in a time zone
>> It will come with a code generator that "compiles" the text files into
>> C# code so that there's no need to deploy additional files with the
>> application. The API's internal data structures are very similar to the
>> tz database records, these are already coded.
>> Currently I'm stuck because of the flexibility of the tz rules. These
>> can define transition times either in local, standard or universal time.
>> Additionally, the caller of my API passes a date and time that is either
>> local or universal. All this needs to be matched correctly. The right
>> rule needs to be selected and there can be ambiguous or invalid times
>> all along the way. It's not only hard to implement, it's also hard to
>> describe, it's very confusing not to have a common base [zone] you can
>> hold on to.
>> I have now read about any manpage and code file from the tzcode
>> distribution, starting with zic.c and going backwards in the list. I
>> think the file localtime.c does the actual conversion but it's hard to
>> read because it contains only few comments and uses short all-lowercase
>> global variable names. I couldn't follow it to its core where the magic
>> happens.
>> I have analysed .NET's TimeZoneInfo implementation with .NET Reflector
>> but it's not half as mighty as what the tz database can express. I also
>> looked at the C# library ZoneInfo, but it uses an incompatible license,
>> reads the text files at runtime and last but not least is quite inexact
>> around transition times which it inacceptable for a calendar
>> application. Also I think it's a good idea to write my own API for it
>> because I'll need a Java port later as well, working on the exact same
>> data.
>> Could somebody assist me in this, please? Are there helpful thoughts to
>> use when implementing such a programme? Right now my biggest problem is
>> the transition times and in consequence finding the right rule to use
>> for a given date and time.
>> --
>> Yves Goergen "LonelyPixel" <nospam.list at unclassified.de>
>> Visit my web laboratory at http://beta.unclassified.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mm.icann.org/pipermail/tz/attachments/20100702/a94c3669/attachment.htm>

More information about the tz mailing list