Time Objects
Last updated at 12:38 am UTC on 17 January 2006
It looks like MaTimeObjects API has changed so as not to clash with new Chronology stuff that has been added to the kernel (3.7?)
For latest API (as in most up to date version of the information on this page) see MaTimeObjectPackageInfo-c-#readme
Time Objects can help you deal with aspects of time using a pleasant API. The core domain class is MaCalendarTime which represents a point on the Gregorian calendar. MaDuration is used to represent a duration of Gregorian time (e.g., seconds, days, etc.). Both are storage efficient, wrapping only a single Integer, with precision to the millisecond.
To get the current time, precise to the millisecond:
MaCalendarTime now
To obtain a duration:
3 minutes
A variety of arithmetic is supported:
3 minutes + 2 seconds
8 hours // 2
(1 hour + 27 minutes) roundTo: 30 minutes
MaCalendarTime now - 30 days
MaCalendarTime now - (MaCalendarTime fromString: ''1969/12/31 23:52:59:999'')
MaStopwatch
is the other cool domain class. This is, literally, a stopwach just like you would use in real life. I use it to time things, such as how long it has been since I last signaled a ProgressNotification, that way I can do them only ever five seconds or so. Inspect this and play with it, it''s simple:
MaStopwatch new start
Matimeobjects.sar