Boost logo

Boost Users :

Subject: Re: [Boost-users] Specific Time Zone In boost::posix_time::ptime
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2010-01-24 23:45:22


On Sun, Jan 24, 2010 at 8:40 PM, Yan Cheng Cheok <yccheok_at_[hidden]> wrote:
> I have the following time :
> 2010-01-25 03:13:34.384 - GMT Time Zone
> 2010-01-25 11:13:34.384 - My Local
>
>
> I wish to convert to timestamp in ms. However, since I only obtain local time string from caller
> "2010-01-25 11:13:34.384"
>
> If I do it this way :
>
>    // ts is "2010-01-25 11:13:34.384" (My Local)
>    boost::posix_time::ptime t(boost::posix_time::time_from_string(ts));
>    boost::posix_time::ptime end(boost::gregorian::date(1970,1,1));
>    boost::posix_time::time_duration dur = t - end;
>    // epoch is 1264418014384
>    // 2010-01-25 11:13:34.384 (GMT)  -- But I want 2010-01-25 03:13:34.384
>    // 2010-01-25 19:13:34.384 (My Local) -- But I want 2010-01-25 11:13:34.384
>    long long epoch = dur.total_milliseconds();
>
> Is there any way to tell boost::posix_time, that the ts string which it receives, is belong to My Local timezone?

I thought posix_time is always supposed to be UTC, you are not feeding
it UTC? There is probably something to convert it though, not sure on
what. Perhaps there was something other then posix_time to feed it
into first?


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