I think I found a bug in Duration>>-
Original Code:
- Code: Select all
- operand
"Synopsis
Answer the result of subtracting @operand from the receiver.
Definition: <Duration>
Answer a <Duration> whose value is the result of subtracting @operand from the receiver.
Parameters
@operand <Duration> unspecified
Return Values
<Duration> new
Errors
None
Implementation Notes
Do it the hard way to stay away from LargeIntegers as long as possible."
| secs msecs |
secs := self totalSeconds - operand totalSeconds.
msecs := self microseconds - operand microseconds.
msecs < 0
ifTrue: [
secs := secs - 1.
msecs = msecs + MicrosecondsPerSecond].
^ self class totalSeconds: secs microseconds: msecs
I think that msecs = msecs + MicrosecondsPerSecond must be: msecs := msecs + MicrosecondsPerSecond .
Proposed Fix:
- Code: Select all
- operand
"Synopsis
Answer the result of subtracting @operand from the receiver.
Definition: <Duration>
Answer a <Duration> whose value is the result of subtracting @operand from the receiver.
Parameters
@operand <Duration> unspecified
Return Values
<Duration> new
Errors
None
Implementation Notes
Do it the hard way to stay away from LargeIntegers as long as possible."
| secs msecs |
secs := self totalSeconds - operand totalSeconds.
msecs := self microseconds - operand microseconds.
msecs < 0
ifTrue: [
secs := secs - 1.
msecs := msecs + MicrosecondsPerSecond].
^self class totalSeconds: secs microseconds: msecs
Regards,
Gabriel