2006-02-09

A lot of work has been put into type-compatibility and interoperability between the Chronos objects that represent dates, times-of-day and date-and-time values and the analogous objects natively present in VisualWorks.

Firstly, instances of Chronos.ChronosTimezone (aliased by Smalltalk.Timezone,) Chronos.TimeOfDay, Chronos.YearMonthDay and Chronos.Timepoint (aliased by Smalltalk.DateAndTime) all respond to the message #asNative with a conversion of themselves into an equivalent instance of Core.TimeZone, Core.Time, Core.Date or Core.Timestamp (respectively.)

If one were using a version of Chronos hosted in some Smalltalk environment other than VisualWorks, the #asNative message would result in an equivalent instance of whatever class is natively used in that environment to represent the same value as is represented by the Chronos object that receives the message #asNative.

Of course, such conversions may lose information, since the Chronos objects have more semantic content that do the equivalent objects native to either VisualWorks or to any of the other Smalltalk environments.

Secondly, instances of Core.TimeZone, Core.Time, Core.Date and Core.Timestamp respond to the message #asChronosValue with a conversion of themselves into an equivalent instance of Chronos.ChronosTimezone, Chronos.TimeOfDay, Chronos.YearMonthDay or Chronos.Timepoint (respectively.)

Conversion from native date/time objects to the equivalent Chronos objects are semantically lossless. For example, when #asChronosValue is sent to a Core.Timestamp, the response is a Chronos.Timepoint that is not bound to any particular time zone, and is therefore invariant to nominal time--which is precisely the semantics of a Core.Timestamp.

#as: -- Answers the conversion of the receiver into either a Chronos.YearMonthDay or a Chronos.Timepoint (depending on whether the receiver is or is not an instance of Core.Date) that represents the same absolute date (and time-of-day, if applicable) as the receiver, but represented according to the calendar specified by the argument

#asDateAndTime -- Answers the conversion of the receiver into a Chronos.Timepoint that represents the same local date and time-of-day as the receiver in the current default Chronos time zone; the answered Timepoint will have Universal-Time-invariant semantics

#asNominalDateAndTime -- Answers the conversion of the receiver into a Chronos.Timepoint that represents the same nominal date and time-of-day as the receiver; the answered Timepoint will have nominal-time-invariant semantics

#in: -- Answers the conversion of the receiver into a Chronos.Timepoint that represents the same local date and time-of-day as the receiver in the the Chronos time zone specified by the argument; the answered Timepoint will have Universal-Time-invariant semantics, unless the argument is <ChronosTimezone nominal>

Chronos.TimeOfDay, Chronos.YearMonthDay and Chronos.Timepoint also respond to the same four messages, with the same semantics.

Thirdly, for almost every instance and class method defined in the inheritance hierarchy of Core.Date there is a corresponding method with the same selector in the inheritance hierarchy of Chronos.YearMonthDay, and for almost every instance and classs method defined in the inheritance hierarchy of Core.Timestamp there is a corresponding method with the same selector in the inheritance hierarchy of Chronos.Timepoint. And all such methods have the same semantics. There are a few exceptions--but almost all of those are private methods (although even some of those are included.)

For example, the following statements/expressions will all work correctly: