Hi,
I'm working on unit tests for TimeCategory and I'm seeing strange behavior in Minute based subtraction.
Subtracting 2.minutes from 12:02:00 AM results in 23:01:00 of the previous day... yet subtracting 120.seconds correctly results in 12:00:00.
Here is the code (note the lines marked "fails!"):
use(TimeCategory) {
//use January 1 to avoid leap years and daylight savings time issues
def midnight = new Date(100, 0, 1, 0, 0, 0)
def oneMinutePastMidnight = new Date(100, 0, 1, 0, 1, 0)
def twoMinutesPastMidnight = new Date(100, 0, 1, 0, 2, 0)
assert (twoMinutesPastMidnight - 60.seconds) == oneMinutePastMidnight //works!
assert (twoMinutesPastMidnight - 1.minute) == oneMinutePastMidnight //fails!!
assert (twoMinutesPastMidnight - 120.seconds) == midnight //works!
assert (twoMinutesPastMidnight - 2.minutes) == midnight //fails!
}
My codebase is from Oct. 16th, 2007.
Thanks in advance.
--
Hamlet D'Arcy