Chronos is one of the many Smalltalk-related blogs syndicated on Planet Smalltalk
χρόνος

Discussion of the Essence# programming language, and related issues and technologies.

Blog Timezone: America/Los_Angeles [Winter: -0800 hhmm | Summer: -0700 hhmm] 
Your local time:  

2007-01-01

Chronos 101: Durational Values

This is the second article in a series of articles that conceptually discuss the Chronos model of time. The first one, Chronos 101: "Points" in Time, addresses the Chronos concept of "points" in time.

Durational Values in Chronos


What is a durational value? It's simply a value that specifies a duration of time, which differs from a "date" or "point-in-time" value in the same way that a "distance" value differs from a "position" value. A "position" value specifies an absolute location by specifying the distance between the location and some absolute reference point (.e.g, "93 million miles from the Sun.") Similarly, a "point-in-time" value specifies an absolute point in time by specifying the duration since (or until) a particular point-in-time and some absolute reference time (e.g., "5765 years since the creation of the world.") A durational value specifies/designates a temporal extent ("how long,") without specifying when the temporal extent begins or ends.

Civil Time versus Scientific Time


Chronos implemements three different types of durational ("temporal extent") values: "scientific time " durations, "civil time" durations and infinite durations.

The fundamental unit of scientific time is the second--all other durational units of scientific time are defined based on the second. The fundamental unit of civil time is the calendar day--with the possible exception of the second, all other durational units of civil time are defined based on the calendar day.

Scientific time defines the length of a second in terms of physical constants, whereas civil time may or may not do likewise--depending on whether the law in a particular legal jurisdiction specifies that the timescale used to define civil time-of-day is Universal Coordinated Time (UTC,) UT1 (modernly synonymous with Greenwich Mean Time,) or some other timescale.

A timescale defines the size of durations of time (temporal extents.) A calendrical system is a specialized timescale that defines the size of years and months in terms of a count of calendar days--or, to put it differently, a calendrical system defines a bidirectional mapping between a count of days and a year-month-day designation.

UTC is a timescale that defines the size of a civil day in terms of scientific seconds. UT1 (GMT) is a timescale that defines the size of a mean solar second as 1/86,400th of a mean solar day. Both define the time-of-day (and hence, the size of a day,) either directly or indirectly, based on Earth's rotation relative to the position of the Sun in the sky.

A scientific second (used by UTC) has an invariant size (as measured by atomic clocks.) A mean solar second (as defined by UT1) is 1/86,400th of a mean solar day. A mean solar second not only hasn't been the same size as a scientific second as it is currently defined since the early 1800s, but its size varies over time (as measured by atomic clocks.)

If civil time is based on the UTC timescale, then the size of a civil day may differ from most other civil days by one second--plus or minus one leap second. Whether or not there are leap seconds, the length of one civil day may differ from another due to either a regularly-scheduled or one-time-only time-of-day change, which might happen when a) civil time makes an annually-recurring and/or regularly-scheduled transition to or from daylight-saving (summer) time, or b) when the standard-time offset from Universal Time for a locale is "permanently" changed--as happened recently in Indiana, and in 1946 in Hawaii (when Hawaii's standard-time offset from Universal Time was changed from -10:30 hours to -10 hours.)

A civil day during which there is a transition from standard time to daylight-saving (summer) time will have 23 hours, not 24 (assuming there is exactly a one-hour difference between standard time and daylight-saving time, which is not universally true.) A civil day during which there is a transition from daylight-saving (summer) time to standard time will (typically, based on the same assumption as above) have 25 hours, not 24 (in which case, some of the hour:minute:second labels on the local time-of-day clock will occur twice in the same day.)

For timescales other than those based (either directly or indirectly) on the mean solar day, there may be yet other complications and discontinuites. For example, if civil time is based on apparent solar time instead of mean solar time, then the size of hours, minutes and seconds will differ continuously during each day (as measured by a typical clock that isn't a sundial, or doesn't emulate a sundial).

Chronos uses instances of the class ScientificDuration to represent durations of scientific time. Chronos uses instances of either CalendarDuration or CivilDuration to represent durations of civil time. Infinite durations of time are represented by instances of InfiniteDuration, of which there are only two: "InfiniteDuration positive" and "InfiniteDuration negative."

Civil Time: CalendarDuration, CivilDuration


A CalendarDuration or CivilDuration represents an extent (duration) of civil time. Since civil time works in such a way that the number of months in a year may vary (which happens in the Hebrew, Chinese, and Hindu lunisolar calendars, for example,) and the number of a days in a month vary, and the number of days in a year vary, and the number of hours in a day vary (as discussed above,) and the number of minutes in an hour and/or day may vary (as implied by the discussion above,) and the number of seconds in a minute, hour or day may vary (e.g., due to leap seconds,) Chronos represents durations of civil time as a vector of elements, where each vector element represents one of the count of years, months, days, hours, minutes or seconds.

A CalendarDuration only specifies a number of years, months and days. A CivilDuration also specifies a number of hours, minutes, seconds and nanoseconds. The number of years, months, days, hours, minutes, seconds and nanoseconds may each be specified to have a different sign (positive/negative,) and any or all of them may be specified to include a fractional value (e.g., "1.5 years -2 months 13.333 days 20 hours -30 minutes 17.44518 seconds.")

Adding a CalendarDuration or CivilDuration that represents one day of civil time to a Chronos point-in-time value results in a point-in-time that is one civil day later, at the same civil time of day, regardless of the number of hours, minutes and seconds actually between the two points in time.

Scientific Time: ScientificDuration


A ScientificDuration represents an extent (duration) of scientific time, where the size of seconds, minutes, hours and days are absolute invariants.

ScientificDurations do not specify any number of months or years, although they may be converted to and from a count of months and years using both a particular timescale and base time. There is no well-defined answer to the question "How many seconds are there in 30 years?" But there is a well-defined answer to the question "How many seconds are there, according to the UTC timescale, in the thirty-year period starting at 1972-01-01T00:00:00Z?"

Adding a ScientificDuration that represents 24 hours of scientific time to a Chronos point-in-time value results in a point-in-time value that is 86,400 scientific (metric) seconds later--which may or may not have the same civil time-of-day as the original point-in-time value.

Part 3: Chronos 101: Intervals of Time


No comments: