Boost logo

Boost Users :

From: Andreas Ntaflos (daff_at_[hidden])
Date: 2006-09-27 04:02:50


On Thursday 21 September 2006 01:23, Jeff Garland wrote:
> Chris Weed wrote:
> > Try this example:
> > Local to UTC Conversion and vice versa:
> > http://tinyurl.com/mloh3
>
> Or:
>
> http://www.boost.org/doc/html/date_time/examples.html#date_time.examp
>les.simple_time_zone
> http://www.boost.org/doc/html/date_time/examples.html#date_time.examp
>les.seconds_since_epoch
> http://www.boost.org/doc/html/date_time/local_time.html#date_time.loc
>al_time.local_date_time
>
> There are now several ways to do timezone conversions and output.
> Hopefully one of them will cover what you need.
>
> Jeff

Thank you both for your replies!

Constructing a posix_time_zone (CET with DST), a ptime from the
timestamp (time_t) using from_time_t() and then creating a
local_date_time object from the constructed posix_time_zone and the
ptime did exactly what I initially wanted.

I also considered the method shown in the Local to UTC Conversion
example which uses the c_local_adjustor, but it's apparently very
undocumented, which is probably why I didn't find it when searching
through the docs. This method seems to have the advantage that I do not
need to hard code the time zone into the program or read it from an
external database file.

BTW: Why would it be dangerous to rely on the machine's time zone
settings? It seems to me that this would be a more robust and
convenient way of applying time zone adjustments.

In fact, how would I be able to run my program in, say, NYC without
constructing a new time zone and recompiling it, should the company I
write it for ever decide to move there?

Just curious.

Thanks a lot!

Andreas

-- 
Andreas "daff" Ntaflos 
Vienna, Austria 
GPG Fingerprint: 6234 2E8E 5C81 C6CB E5EC  7E65 397C E2A8 090C A9B4



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