[GOODIE] Time Objects

Chris Muller afunkyobject at yahoo.com
Thu Jan 30 18:58:26 UTC 2003


FYI, My preferred way of working with Gregorian time is now auto-installable
from SqueakMap.

http://marvin.bluefish.se:8000/sm/package/5570b593-0ca3-462b-827c-4b3a746e3205

>From the readmeText:
----------
I can help you deal with aspects of time using a pleasant API.  The core domain
class is MaCalendarTime, which can represent either a point on the Gregorian
calendar, or a duration of Gregorian time (e.g., seconds, days, etc.). 
MaCalendarTime is storage efficient, wrapping only a single Integer, and is
precise to the millisecond.

To get the current time:

	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



__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



More information about the Squeak-dev mailing list