Skip to content

Latest commit

 

History

History

tc39-2023-07

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
theme paginate style
gaia
true
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css'); @import url('https://cdn.jsdelivr.net/npm/hack-font@3/build/web/hack-subset.css'); @import url('https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,400;0,700;1,400;1,700&display=swap'); code { font-family: Hack; } section { font-family: Rubik, sans-serif; letter-spacing: 0; } section.lead.invert { text-shadow: 0 0 10px black, 0 0 20px black; } section.smaller-type li { font-size: 85% } marp-pre code, marp-pre { background-color: #042029; } .hljs-string { color: #8ae234; } .hljs-number, .hljs-literal { color: #729fcf; } .hljs-params { color: #e9b96e; font-style: italic; } .hljs-built_in { color: #fce94f; font-weight: bold; } .hljs-title.class_ { color: #fce94f; text-decoration: none; font-weight: bold; } .hljs-title.function_ { color: #c8a8c4; } .hljs-keyword { color: #fcaf3e; font-weight: bold; } .hljs-attr { color: #e9b96e; } .hljs-variable { color: red; font-weight: bold; } /* .hljs-comment, .hljs-regexp, .hljs-symbol */

Temporal

Philip Chimento Igalia, in partnership with Bloomberg
TC39 July 2023


Progress update

  • Presenting integer arithmetic change discussed in previous plenaries
  • Also presenting two normative changes arising from implementor discussions
  • All known discussions settled; these are the last expected changes
  • Implementation continues (JSC, LibJS, SpiderMonkey, V8)

IETF standardization progress (#1450)

  • IETF document currently in last call
  • Some suggestions from area directors, and one complaint
  • Complaint seems to be able to be handled with discussion

Normative changes


Integer math in durations (PR #2612) (1/3)

  • Storage doesn't change; one f64-representable integer for each unit
    • "90 minutes" preserved unless explicitly balanced to "1 hour 30"
  • Calculations with time units (days* through nanoseconds) use "normalized form", s × 10⁹ + ns
    • |s| ≤ max safe integer
    • |ns| ≤ 999,999,999
    • Can be implemented as: i96 ns; i64 s + i32 ns; f64 s + f64 ns
    • At end of calculation, converted back to integer-per-unit for storage

*Why are days a time unit? We allow calculations without calendar, and assume 24-hour days in that case.


Integer math in durations (2/3)

  • Calendar units years, months, weeks, all limited to maxuint32
    • |N| < 2³² for N = y, mon, w
    • Why not maxint32? Because sign is common to all units
    • Implementations can choose to store as u32 instead of f64
  • Note, performing calculations with relativeTo date can still fail
    • 2³²-1 years ≫ representable range
  • With limits, calculations in loops no longer necessary
    • Concern emerged in review of SpiderMonkey implementation

Integer math in durations (3/3)

  • Spec text encapsulates all 96-bit operations in AOs
  • Can be changed editorially to explicitly be 64+32 or seconds+subseconds, if implementations prefer
  • Few observable effects, but some durations no longer allowed
// e.g. no longer allowed:
Temporal.Duration.from({ seconds: Number.MAX_VALUE })
Temporal.Duration.from({
  seconds: Number.MAX_SAFE_INTEGER,
  milliseconds: 1000
})
// Maximum duration now accepted:
Temporal.Duration.from({