Constants for the minimum and maximum values of each Temporal type · Issue #23 · js-temporal/proposal-temporal-v2 · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instant, ZonedDateTime: ±1e8 24-hour days around the Unix epoch (±86400_0000_0000_000_000_000n nanoseconds), same as legacy Date
min value: -271821-04-20T00:00:00Z
max value: +275760-09-13T00:00:00Z
PlainDateTime: such that any valid Instant can be converted to a PlainDateTime at any UTC offset in the range of ±23:59:59.999999999
min value: -271821-04-19T00:00:00.000000001
max value: +275760-09-13T23:59:59.999999999
PlainDate: such that any valid PlainDateTime can be converted to a PlainDate
min value: -271821-04-20
max value: +275760-09-13
PlainYearMonth: such that any valid PlainDate can be converted to a PlainYearMonth
min value: -271821-04
max value: +275760-09
It's not currently possible to get these values from JS, except by knowing what they are through out-of-band documentation.
One recommendation would be to include constants on each type's constructor (e.g. Temporal.Instant.MAX_VALUE). This would avoid polluting top-level autocomplete with a large number of rarely used options. Also it would match other types' behavior like Number.
What calendar would the min and max values for ZonedDateTime, PlainDate, PlainDateTime, and PlainYearMonth have? iso8601 as the "machine" calendar might be the answer here.
What time zone would the min and max values for ZonedDateTime have? Unlike the calendar, it seems like it could be harmful to choose UTC as the time zone.
Would we have max and min values for PlainTime (00:00–23:59:59.999999999)?
Would we have max and min values for PlainMonthDay (01-01–??-??)? The max value depends on the calendar. For example, the Gregorian calendar would have 12-31 as the max value, and the Hebrew calendar would have a max value of PlainMonthDay.from({ monthCode: 'M12', day: 29 })(?)
The text was updated successfully, but these errors were encountered:
Several Temporal types have an allowed range of values (tc39/proposal-temporal#24):
It's not currently possible to get these values from JS, except by knowing what they are through out-of-band documentation.
One recommendation would be to include constants on each type's constructor (e.g.
Temporal.Instant.MAX_VALUE
). This would avoid polluting top-level autocomplete with a large number of rarely used options. Also it would match other types' behavior like Number.Advantages:
These are useful for input validation, expanded polyfills, and tests.
Concerns:
None, this seems useful to have.
Prior art:
datetime.datetime.max
, etc.chrono::MAX_DATE
, etc.Constraints / corner cases:
iso8601
as the "machine" calendar might be the answer here.PlainMonthDay.from({ monthCode: 'M12', day: 29 })
(?)The text was updated successfully, but these errors were encountered: