More on Dates
Francisco Garau
francisco.garau at gmail.com
Tue Apr 11 06:53:44 UTC 2006
Thanks for the suggestions on my previous post.
I am aware of the work done in Chalten by the Mercap guys. In fact, I read
it quite carefully and took several ideas from there. One of the things I
like most is the immutability of date objects.
I want that the printString of a date returns an equivalent objects. In
code:
'30-Apr-06' actualDate printString
=> '2006 year april day30'
>From the suggestions received, the one using the comma seems the more
elegant (2006 year april, 30). But it requires parenthesis. Once a date
receives the #weekday message, it calculates the julian day number, and from
then on the weekday is cached. Now the printString is getting bigger.
'30-Apr-06' actualDate weekday; printString
=> '2006 year april day30 sunday'
Now I have another method to generate these boring ones.
TmActualDate class>>generateMethods
#(sunday monday tuesday wednesday thursday friday saturday) collect:
[:each |
self fakeCompile:
(String streamContents:
[:stream |
stream
nextPutAll: each; cr; tab;
nextPutAll: '^ self' ] ) ]
- Francisco
PD: During Esug 2004, Dan Ingalls showed Smalltalk-72 and the original
Smalltalk-80 running inside Squeak. Does anybody know how to get those
images?
More information about the Squeak-dev
mailing list
|