I have a question about the DateAndTime and Duration classes available
from Ian's web site. The questions relate to the following workspace
session:
1) a := DateAndTime now.
2) a (=> 2001-11-10T00:45:39.29+13:00)
3) b := DateAndTime now.
4) b (=> 2001-11-10T00:46:07.31+13:00)
5) a (=> 2001-11-10T00:46:07.31+13:00)
6) a asSeconds (=> 6314103633929/100)
7) b asSeconds (=> 6314103636731/100)
In line 1 I set a to the current date/time. It prints out correctly in
line 2. In line 3 and 4 I do the same for b. (=> is the result of
Ctrl+D).
Note that line 5, I redo the printing of the value of a and it now
displays the same as b. But looking at lines 6 and 7 you can see they
have a different seconds value.
The same problem occurs reading values line 'a minute', 'b minute',
etc. They are always the same as each other even though the times are
actually different as noted by 'asSeconds'.
Looking at the source it seems that the results of 'hour', 'minute',
etc are cached in some class slots making them the same for all
instances. You always get the value of the last DateAndTime instance
created. Is this the correct behaviour?
As a workaround I'm just using the 'asSeconds' method.
Chris.
--
http://www.double.co.nz/smalltalk