Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2004-02-11 09:30:54

On Tue, 10 Feb 2004 11:31:29 -0600, charles.crain wrote
> I am having a hard time figuring out how to construct a ptime from a
> "flat" time (i.e., some number of time units since some epoch) other
> than a time_t. For instance, we have a lot of software here at work
> that represents time as a double-precision floating point number of seconds
> since 1/1/1904 00:00:00 GMT. As you can imagine, any sensible
> number is bigger than a 32-bit integer.


> I would like to be able to construct a ptime something like this:
> ptime p(date(1904, Jan, 1), microsec(boost::int64_t(float64_time *
> 1000000.0));
> ...or even better...
> ptime p(date(1904, Jan, 1), float64_time);
> Problem is, it seems the constructors to most time_duration types use
> longs, even if they use int64's internally. I can't get the above example
> to work with any time past 12/31/1904 23:24:12, which just happens
> to be 0x80000000 microseconds past 1/1/1904.

Yes, that is at least partially because the library supports multiple internal
representation options -- not all of which are int64 internally. So to do
this correctly you will have to subtract the date part out of the offset,
construct the date, and then add the time duration. Give me a day or so to
work on an example.

> Another thing I would like to do is construct a ptime from a Win32
> FILETIME, which is an int64 number of 100ns intervals since 1/1/1601.
> Something like this:
> ptime p(date(1601, Jan, 1), nanosec(100 * fileTime));
> Is there a better way to do this? I am using MSVC 6.0 SP5 with Boost
> 1.31.0.

No. It looks like we are going to need to change the interface to support
this correctly. This would be nice to add to the library as I expect I'll be
needing this myself at some point :-)


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