Boost logo

Boost Users :

From: Jeff Garland (jeff_at_[hidden])
Date: 2003-10-28 17:47:31


On Mon, 27 Oct 2003 14:36:57 +0100, Erik Thiele wrote
> hi.
>
> i am trying to convert between UTC and CEST/CET (Europe/Berlin)
>
> i don't find documentation or suitable functions in the Wiki, the
> examples or the documentation.

Eric -

The local time conversion code is still experimental which is why it is
undocumented.

 
> also i don't understand the sourcecode of the time zone stuff. but i
> found that eu_dst_trait exists, but don't know what that is and how
> to use it.
>
> any ideas?

You can try something like this:
   typedef boost::date_time::eu_dst_trait<date> eu_dst_traits;
   typedef boost::date_time::dst_calc_engine<date, time_duration,
eu_dst_traits> eu_dst_calc;
   //adjustment from UTC is +2
   typedef boost::date_time::local_adjustor<ptime, 2, eu_dst_calc>
eu_cet_adjustor;

    ptime t1(...); //construct a 'local time'
    ptime t2 = eu_cet_adjustor::local_to_utc(t1);
    ptime t3 = eu_cet_adjustor::utc_to_local(t2);

I believe this code works, but do some tests to make sure. You can find
examples of code like this in libs/date_time/test/testlocal_adjustor.cpp and
testdst_rules.cpp.

As I said, this is experimental code and I think this approach has proven to
be rather cumbersome. I'm working on a 'dynamic timezone' class that will
provide the ability to construct zone and offset data at runtime instead of
using traits for timezone configurations. This won't be in the 1.31 release,
however...

Jeff


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net