|
Boost Users : |
Subject: [Boost-users] [DateTime] from time_t to ptime and back - or not
From: Christoph Duelli (duelli_at_[hidden])
Date: 2010-08-20 11:23:15
[I am using Boost 1.43.0 on linux, gcc 4.4.1]
I am having trouble with date_time's ptime.
I am passing it a time_t, and store that in a ptime object.
When I retrieve the time_t, I am getting a different value than the one I
passed to it originally.
(the difference seems to be 2 hours - in all probability due to UTC vs local
time issues).
Code:
time_t now = time(NULL);
boost::posix_time::ptime pt = boost::posix_time::from_time_t(now);
struct tm tm = to_tm(pt);
time_t should_be_now = mktime(&tm);
BOOST_CHECK_EQUAL(now, should_be_now);
fails for me: now is by 7200 seconds (i.e. 2 hours) ahead of.
Is this a bug in date_time or am I just failing to use it properly?
Thank you,
and best regards
Christoph
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