date_time and negative time_durations

hi the docs of time_duration say that minutes() returns 0..59 and seconds() return 0..59. this is not true, the correct answer is, minutes() returns -59..+59 and seconds() also. the handling of negative durations is not fully documented. i.e. is it true that the sign of hours(),minutes() and seconds() is always equal to each others sign? x=time_duration(anything...); y=x.invert_sign(); is the following true for all values of x: abs(x.hours()) == abs(y.hours()) abs(x.minutes()) == abs(y.minutes()) abs(x.seconds()) == abs(y.seconde()) but whatever way you document it, it should somehow be documented. to continue on my work i now make the assumption that in the following assertions are true for all values of x: if (x.is_negative()) x = x.invert_sign(); assert(x.hours()>=0); assert(0<=x.minutes()<=59); assert(0<=x.seconds()<=59); i hope this assertions are correct for all values of x !!!!! :) cya! erik

On Wed, 19 Jan 2005 13:54:22 +0100, Erik Thiele wrote
hi
Hi -- sorry to be slow on the response...anther busy week...
the docs of time_duration say that minutes() returns 0..59 and seconds() return 0..59. this is not true, the correct answer is, minutes() returns -59..+59 and seconds() also.
Yes, you are correct we need to fix the docs.
the handling of negative durations is not fully documented. i.e. is it true that the sign of hours(),minutes() and seconds() is always equal to each others sign?
Yes -- the sign is reflected in all the components.
x=time_duration(anything...); y=x.invert_sign();
is the following true for all values of x:
abs(x.hours()) == abs(y.hours()) abs(x.minutes()) == abs(y.minutes()) abs(x.seconds()) == abs(y.seconde())
Yes.
but whatever way you document it, it should somehow be documented.
Agree.
to continue on my work i now make the assumption that in the following assertions are true for all values of x:
if (x.is_negative()) x = x.invert_sign(); assert(x.hours()>=0); assert(0<=x.minutes()<=59); assert(0<=x.seconds()<=59);
i hope this assertions are correct for all values of x !!!!! :)
Yes, they are. We'll work on fixing the docs -- thx for the report. Jeff
participants (2)
-
Erik Thiele
-
Jeff Garland