[ENH] Timestamp

Norton, Chris chrisn at Kronos.com
Wed May 1 02:40:03 UTC 2002


Hannes Hirzel asked (in the DateAndTime thread) what my Timestamp class does
and if it works with 3.2.  Well, it files into my 3.2 alpha image just fine
(updated to 4664).  I'm sorry I don't have a 3.2 gamma image handy.  The
class is fairly straightforward, Hannes, if you want to take a quick look at
it.

As was noted in the preamble, this class does not implement time zones, but
I think it is useful even without them.  If time zones are also needed, I
suppose someone could look at the work that was done by Lex Spoon and
others.  In any case, my class is very lightweight (no refactoring of the
base classes is necessary to use Timestamp in your image). 

I implemented Timestamp when I needed to port some of my code from VSE to
Squeak.  At the time, I banged on this code pretty hard, so I expect that it
should work as you would expect.

I'm sorry I haven't had time to write SUnit tests for this.  But before
sending this note to the list, I inspected each of the following statements
(see below), exercising a good chunk of the protocol -- everything seemed
fine.

I hope you find this class as useful as I do.  I imagine that it could be
used quite handily in such applications as Celeste, the PDAMorph, etc.
Squeak really deserves to have a Timestamp class; lugging dates and times
around in arrays is too painful.

Cheers,

---==> Chris

PS>  For history buffs & people who are already using my Timestamp class: in
the original changeset (posted to the list in October of 2000), I had named
the class TimeStamp.  Since that time, I've discovered that timestamp is a
word in its own right, so I changed the name of my class to Timestamp.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Here are some protocol tests:

Timestamp current
Timestamp date: (Date fromString: '1/1/2002') time: Time now
Timestamp fromSeconds: 1000
Timestamp fromString: '1/2/1002 4:44:00pm'
Timestamp midnight
Timestamp midnightOn: (Date today)
Timestamp noon
Timestamp noonOn: (Date today)
Timestamp current minusDays: 4
Timestamp current minusSeconds: 500000
Timestamp current plusDays: 4
Timestamp current plusSeconds: 500000
Timestamp current asDate
Timestamp current asSeconds
Timestamp current asTime
Timestamp current asTimestamp
Timestamp current dateAndTime
Date today asTimestamp
Time fromString: '11:55:23 am'
Time midnight
Time noon


-------------- next part --------------
A non-text attachment was scrubbed...
Name: Timestamp.2.cs.gz
Type: application/octet-stream
Size: 2098 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20020430/925cd7da/Timestamp.2.cs.obj


More information about the Squeak-dev mailing list