Jump to content

Wikifunctions:Type proposals/Moment in time

From Wikifunctions

Use/Why

This type would allow for the representation of a moment in time, something critical for many functions. It would allow infinite resolution. Some examples:

  • Moment in time to Unix time
  • Add to Moment in time.
  • Distance between the Earth and Moon at a given moment.

Type

The type created by this proposal would consist of two keys:

  1. One key would represent the date of the moment in time, of the Gregorian Calendar Date type
  2. one to represent the fraction of the day completed, represented by the Rational number type.

Renderer/Parser

The renderer should display the ISO 8601 representation of the time. The parser should accept and convert one.

Converting to code

This would convert as a 6 key object:

  • K1: the year in ISO 8601, int in Python, BigInt in JavaScript
  • K2: the month, 1-12 in python and 0-11 in JavaScript
  • K3: the day of the month
  • K4: the hour of the day, 0-23
  • K5: the minute of the hour, 0-59
  • K6: the second of the minute, 0-59 (ignore leap seconds, this type implements the "Feeglian calendar" (as named by User:99of9)), would be represented by a rational for infinite resolution.

Timezones

This proposal would not support different timezones, only UTC, because the use cases for timezones should be fulfilled by a different type. This is to provide an objective, accurate, and universal description of time. In the future, a type should be created to handle standard times, instead of moments in time. As such, this type is for representing moments in time, not a time relative to the Earth's rotation or position relative to the sun

Alternatives

  • We could replace K4-K7 with one rational number, but this might make it hard to interact with native time types
  • We could not use the "Feeglian calendar", but the date type effectively does use the "Feeglian calendar", so we'd be inconsistent with that.

Comments