Boost logo

Boost :

Subject: Re: [boost] [DateTime] Converting ptime to real POSIX Time
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2010-08-17 07:08:38

Artyom wrote:
> 1. POSIX Time (see
> is always considered Time in seconds from 1970-JAN-1 00:00:00 UTC
> not including leap seconds.

Of course.

> However ptime can be constructed from "local_time" which is totally
> contradicts a well known definition of POSIX time.

There's no contradiction. Local time can always be converted to POSIX time as both represent a specific point on the timeline. The ptime created from a local_time accounts for time zone and DST during the conversion.

> 2. I can't find any way to convert it to "number" POSIX time.
> I can convert it
> to time_t and from time_t but if I need a better accuracy
> -milli-seconds,
> nano-seconds etc.
> it seems to be impossible according to docs.
> How can I convert it to more accurate representation?

You quoted the definition of POSIX time above. It is the number of seconds, not fractional seconds since the epoch. Boost.Date Time does the same. To manage more precision, you must track the fractional seconds separately.

> Is there any way to get a notice about how ptime was created, with
> universal time scale or local time scale, also I there a way to
> get UTC POSIX time from ptime even if it was created from
> local time.

Those are not issues. A ptime is always POSIX time.

Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.

Boost list run by bdawes at, gregod at, cpdaniel at, john at