Boost logo

Boost Users :

From: Beth Jacobson (bethj_at_[hidden])
Date: 2006-05-23 13:28:21


Jeff Garland wrote:
> Seweryn Habdank-Wojewódzki wrote:
>> Hi!
>>
>> I wonder if there is any posibility to change boost::datetime result class eg.
>> long to any bignum class eg. from GMP library or double type.
>
>
>> It is important question for calculation distance between let's say 1900 and
>> 2100 and using method eg. total_seconds(). There is no methods like
>> total_minutes(), total_hours(), total_days() and so on, so if I would like to
>> have a distance in days I have to calculate distance in seconds and
>> recalculate it to days, but for big distances total_seconds() exceeded long
>> ranges.

ticks()/ticks_per_second() will give you the correct number of seconds.

>
> Doubles are explicitly not used to avoid the precision issues in
> calculations. However, the library is designed with templates that
> allow exactly this sort of internal representation replacement. And, in
> fact, the normal internal representations for times use either 64 or 96
> bits -- so I believe you're use case is already covered. Have you tried it?
>
> Jeff

I think Seweryn was talking about this:
long total_seconds()
^^^^

You can have a time duration of 200 years, but the number of seconds in
200 years is too large to fit in a long, so the total_seconds() function
won't work.

According to the doc, ticks() returns a boost::int64_t. Couldn't
total_seconds(), total_milliseconds(), etc. do the same?

Regards,
Beth


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net