|
Boost : |
Subject: Re: [boost] [gsoc 2013] draft proposal for chrono::date
From: Howard Hinnant (howard.hinnant_at_[hidden])
Date: 2013-05-05 13:37:00
On May 5, 2013, at 1:09 PM, Anders Dalvander <boost_at_[hidden]> wrote:
> Sorry about that, should be:
>
> chrono::date d = year(2013) / may / day(5);
> chrono::time t = hours(12) + minutes(34) + seconds(56);
> chrono::date_time dt(d, t);
> // Here `dt` should be the representation of May 5th 2013 at 12:34:56, but that in turn occurred at different instants for different people around the world.
> // In order to convert it to a `chono::system_clock::time_point` a timezone would be needed:
> chono::system_clock::time_point instant = dt.in_timezone(chrono::timezones::utc); // or perhaps `dt.in_utc()` for short.
Fwiw, I just ran this program fragment:
day_point d = year(2013) / may / day(5);
auto t = hours(13) + minutes(34) + seconds(30);
auto dt = d + t;
auto EDT = hours(-4);
dt -= EDT;
auto dt_now = system_clock::now();
auto diff = dt_now - dt;
std::cout << duration_cast<seconds>(diff).count() << " seconds\n";
And it output:
1 seconds
Howard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk