Boost logo

Boost :

From: charles.crain_at_[hidden]
Date: 2004-02-10 12:31:29


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.

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.

-Charles


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk