On Mar 2, 4:19*pm, Lew <no...@lewscanon.com> wrote:
> jasonc wrote:
> > I'm having trouble coming up with a good approach to take here. The
> > main issue is daylight savings time. It's fairly trivial for me to
> > write a Java program that builds a list of timezone ID's and their
> > associated GMT offsets, and using that list to give the C++
>
> Especially if you use
> <http://java.sun.com/javase/6/docs/api/java/util/TimeZone.html>
>
> > application the info it needs for the conversion, but I have not been
> > able to come up with a good way to support daylight savings time (and
> > also to support the dst-adjusted display names of timezones, e.g.
> > "EST" vs "EDT" for EST5EDT) in the C++ application short of
>
> "EST" can be UTC+11, UTC+10 or UTC-5.
> "EDT" can be UTC+11 or UTC-4.
> Other such ambiguities abound.
> <http://www.timeanddate.com/library/abbreviations/timezones/>
>
> > reimplementing all of the logic for every timezone ID by hand -- which
> > is less than ideal.
>
> Why does the C++ have to handle this? *Why not let the Java do it?
Well, they're two separate applications in a large business system; I
can't combine them like that, unfortunately. Also, I'm actually only
storing the hour and minute, not a date, it's sort of a strange
situation that doesn't need to be explained here but the Java side
doesn't have quite enough info to convert the time into a known
timezone that the C++ app can assume.
> Between Calendar, TimeZone and the upcoming JSR 310 stuff
> <http://today.java.net/pub/a/today/2008/09/18/jsr-310-new-java-date-ti...>
> Java is in the best position to handle it.
I figured it out, though. Or rather, got some good info from the Joda
mailing list. Joda (and I think Java's implementation as well) uses
the tz database here for all the timezone IDs:
http://www.twinsun.com/tz/tz-link.htm
As it turns out, there's both a GNU C implementation, and for C++,
boost provides a date/time library with time zone support based off
the same database:
http://www.boost.org/doc/libs/1_38_0...me.tz_database
Pretty handy! So I can share the timezone IDs between the two, and
both have date/time packages that can deal with the same set of
timezones (Joda and boost). So this is the solution; thought I'd post
it here in case anybody found this thread some day.
Thanks for your replies,
Jason