
Beth Jacobson wrote:
Time durations can be divided by an integer to produce a duration (e.g. hours(1)/60 == minutes(1);), but can't be divided by another duration to produce an integer (e.g. hours(1)/minutes(1) == 60;).
Could this be added to time_duration.hpp:
int operator/(const duration_type& d) const { return (ticks_ / d.ticks_); }
Reasonable -- of course it will have the usual integer division issues.
or maybe better, this:
double operator/(const duration_type& d) const { return (static_cast<double>(ticks_) / d.ticks_); }
The same thing can already be accomplished already with duration1.ticks()/duration2.ticks(), but duration1/duration2 seems more natural and fits well with the rest of the date_time operators.
Well, I've managed to avoid injecting any "fuzzy floating point logic" into date_time up till now. I guess I'd like to hear a compelling use case from you or others as to why this is really needed. Partially because if I add it to date_time I might have to add it to my standard proposal and defend it. In the current version of the proposal I've tried to hone down the interface footprint as much as possible without leaving out anything vital. Be aware the one of my arguments will likely be that it's trivial enough for you to write: //beths_time_extensions.h namespace boost { namespace posix_time { double operator/(const time_duration& lhs, const time_duration& rhs) const { return (static_cast<double>(lhs.ticks()) / rhs.ticks()); } }} I have a whole directory full of 'jeffs cool date time extenstions' that will never make it into the library because they're just not vitally important to the core problem. Finally, if you write it you get to handle the support email if the double math or comparisons fail you -- personally I don't trust it ;-) Jeff