|
Howard,
> Sometimes adding times or scaling a time can set 'milliseconds' off the
> bounding range, which might be a hard-to-find bug.
>
> What if we take modular of "24*60*60*1000" before we set 'milliseconds'
> .
>
> Time>>setMilliseconds: anInteger
>
> milliseconds := anInteger rem: 24*60*60*1000
I'd be more inclined to trap it as an error
Time>>fromMilliseconds: anInteger
self assert: [anInteger < ##(24*60*60*1000)].
"blah"
The Time class is intended to be used as a value representing "time of
day". Any attempt to set it to represent a value greater than 24 hours
should be seen, in the context of the Time class, as an error. If you
have to adjust a value to make it fit then, IMHO, that should be done
outside of the Time class.
You might want to have a look at the implementation of the ANSI Duration
class in my goodies. It represents any duration of time, not limited to
24 hours, and might be easier to use if you are manipulating longer times.
--
Ian
Use the Reply-To address to contact me (limited validity).
Mail sent to the From address is ignored.
|