|
|
As mentioned in the section, ``The relationship between Time, Place, and Duration'', subtracting two Times yields a Duration, while adding a Duration to a Time or subtracting a Duration from a Time yields another Time. The Times and Durations resulting from these operations always appear (when viewed) as normalized values. For example:
Time t = Time(1987,Time::july,3)+Duration::hours(19); Duration d = Duration::hours(7); cout << t+d << endl;
prints:
07/04/87 02:00:00
Adding (or subtracting) a Duration to (from) a Time may produce a result outside the range [Time::MIN(),Time::MAX()]. Although this condition is not checked for, it normally results in overflow (underflow). When this occurs, a future Time can become a Time in the past, and vice-versa. This need not normally concern most programmers.
Taking the difference between two Times which differ by more than Duration::MAX() can also cause (Duration) overflow. Again, this condition is not checked for, and it normally yields a Duration with the wrong sign and magnitude. Again, this need not concern most programmers.