Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
UTCDateAndTime
Last updated at 3:31 am UTC on 21 June 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.


Traditional implementation

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.

New implementation

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.

 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.

Historical versions

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.