Last updated at 8:53 pm UTC on 22 October 2018
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.
Contributed by Dave Lewis. License is MIT.
UTCDateAndTime is maintained at http://www.squeaksource.com/UTCDateAndTime. Please refer to that repository for loading UTCDateAndTime.
The traditional implementation of the date and time class called DateAndTime uses instance variables
and calculates its magnitude based on those variables in conjunction with the local TimeZone.
UTCDateAndTime replaces this with an implementation using instance variables
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.
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.
With regard to serialization, it is handled as follows:
Time: 8 December 2016, 8:23:28.539757 pm
Fix readDataFrom:size: and implement storeDataOn:
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 from the original development:
Load UTCDateAndTime from a SAR archive (original procedure as of May 2015) UTCDateAndTime-dtl-20150526.sar
The updated SAR for Squeak trunk as of March 2016 is UTCDateAndTime-dtl-20160306.sar
UTCDateAndTime was originally posted as UtcDateAndTime-dtl.sar on the squeak-dev list http://lists.squeakfoundation.org/pipermail/squeak-dev/2014-May/178325.html under the subject line "A UTC based implementation of DateAndTime". A simple performance test utility was also included LXTestDateAndTimePerformance.st.