Skip to content

Problem with generating Durations from non-numeric input components #2112

Closed

Description

NaN is replaced with zero by ToIntegerWithoutRounding step 2, but this leads to some surprising and IMO bad consequences:

new Temporal.Duration(Symbol(2022)) // TypeError 👍
new Temporal.Duration(0.5) // RangeError 👍
new Temporal.Duration(NaN) // => PT0S 😱
new Temporal.Duration("foo") // => PT0S 😱
new Temporal.Duration(/regex/) // => PT0S 😱
new Temporal.Duration(Temporal) // => PT0S 😱
Temporal.PlainDateTime.from("2022-03-20T00:00").add({days: Symbol(0)}) // => TypeError 👍
Temporal.PlainDateTime.from("2022-03-20T00:00").add({days: 0.5}) // => RangeError 👍
Temporal.PlainDateTime.from("2022-03-20T00:00").add({days: NaN}) // => 2022-03-20T00:00 😱
//…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

behaviorRelating to behavior defined in the proposalfeedbackhas-consensusnormativeWould be a normative change to the proposalspec-textSpecification text involved

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions