$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Philip Miller (pwmiller_at_[hidden])
Date: 2003-09-04 09:43:30
Jeff Garland wrote:
> On Wed, 03 Sep 2003 17:09:08 -0400, Philip Miller wrote
> > David Abrahams wrote:
> >
> > > I'm trying to get a ptime relative to 1/1/1970, so I did:
> > >
> > > using namespace boost::date_time;
> > > ptime d;
> > > ...
> > > boost::posix_time::time_duration since_1970 = d - 1/Jan/1970;
> > >
> > > Error.
> > >
> > > Since it is a completely lossless conversion (like an upcast), I'd
> > > like to see boost::date -> boost::posix_time::ptime implicit
> > > conversions added.
> >
> > Can you elaborate on the problem? I, too, am doing lots of
>
> I believe that Dave is asking for a non-explicit constructor for
> ptime from date. But he is also using an expression template extension
> to allow the 1/Jan/1970 to compile.
I have grown to dislike non-explicit constructors, so I like the current
interface. I also greatly prefer the syntax of date(1970,1,1) to 1/Jan/1970.
Just my two cents.
> > So, I would like to see a standard time_duration accessor that returns
> microseconds rather than the
> > compile-time dependent fractional_seconds.
>
> I think what you want is really 'total_microseconds', right? hours, minutes,
> and seconds provide a 'normalized count' which is really for 'breakdown
> printing' (eg: 10:09:08). And presumably if your time_duration was using
> nanoseconds you might what total_microseconds to round up/down appropriately?
No, I am simply looking for an easy way to convert between boost::date_time ptime
and time_duration instances to the conventional 64-bit seconds/microseconds since
1/1/1970 representation of time. So, what I really want (at least I think I
want) are total_seconds, fractional_microseconds member methods to time_duration.
No rounding would be required for total_seconds, but rounding would be required
for fractional_microseconds.
I hope this makes sense, and please take my comments as minor suggestions for what
has proven to be a great library for me to use in my applications. Thanks for
your effort!
Thanks,
Phil