UTCDateAndTime is a UTC based implementation of class DateAndTime with one instance variable representing the magnitude of the point in time, and another representing local time zone offset.
As of January 2019 this project has been merged in Squeak trunk and is now included in package Chronology-Core.
Traditional implementation
The traditional implementation of the date and time class called DateAndTime uses instance variables
seconds
offset
jdn
nanos
and calculates its magnitude based on those variables in conjunction with the local TimeZone.
New implementation
UTCDateAndTime replaces this with an implementation using instance variables
utcMicroseconds
localOffsetSeconds.
This represents time magnitude as elapsed microseconds since the Posix epoch,
with localOffsetSeconds representing local offset from UTC.
The magnitude is used for comparison and duration calculations, and the local offset is used for displaying this magnitude in the context of a local time zone.
The implementation ignores leap seconds, which are adjustments made to maintain earth rotational clock time in synchronization with elapsed seconds.
DateAndTime class>>now
will use #primitiveUtcWithOffset to obtain current time in UTC microseconds with current local offset in seconds. The primitive provides an atomic query for UTC time and local offset as measured by the OS platform.
If primitiveUtcWithOffset is not available, the traditional implementation is used, which relies on a primitive for microseconds in the local time zone and derives UTC based on the TimeZone setting.
These changes are not easily reversed. When initially loading from SS3, the first four MCZ files must be loaded individually and in sequence. During the loading process, instances of DateAndTime in the image must be converted to new formats. Currently this is a one way process, so save your image prior to loading UTCDateAndTime. Installing the changes takes time because the become operations are slow, and this may give the impression that the image has locked up. Be patient, and in due time all will be well.
Migration
With regard to serialization, it is handled as follows:
Strategy - Always store instances of DateAndTime as if they were the old
format with seconds, offset, jdn, nanos. This ensures that serialized
instances such as those in the snapshot.bin of a Monticello archive can
be read by any image.
Implementation is in DateAndTime>>readDataFrom:size: and DateAndTime>>storeDataOn:
and I expect that both Fuel and Ma-Serializer will need similar handling.
Historical versions
Historical versions from the original development: