Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Change Temporal.Duration constructor to throw if given a non-integer Number #1832

Closed
ptomato opened this issue Sep 16, 2021 · 0 comments · Fixed by #1872
Closed

Change Temporal.Duration constructor to throw if given a non-integer Number #1832

ptomato opened this issue Sep 16, 2021 · 0 comments · Fixed by #1872
Assignees
Labels
needs plenary input Needs to be presented to the committee and feedback incorporated spec-text Specification text involved
Milestone

Comments

@ptomato
Copy link
Collaborator

ptomato commented Sep 16, 2021

Discussed in the champions meeting of 2021-09-16, and originally raised by @rkirsling in #1704. The Temporal.Duration constructor, unlike Temporal.Duration.from(), drops the fractional part of numbers given to it. from() throws if given a non-integer number, because Temporal.Duration.from('PT1.1H') results in 1 hour, 6 minutes, but Temporal.Duration.from({ hours: 1.1 }) cannot be exact, yet should not silently drop the .1, as discussed in #938.

Temporal.Duration(0, 0, 0, 0, 1.1) should now throw the same exception as Temporal.Duration.from({ hours: 1.1 }) in order to be consistent and avoid the surprise to users of silently dropping the .1.

@ptomato ptomato added spec-text Specification text involved needs plenary input Needs to be presented to the committee and feedback incorporated labels Sep 16, 2021
@ptomato ptomato added this to the Next milestone Sep 16, 2021
ptomato added a commit that referenced this issue Oct 14, 2021
The Temporal.Duration constructor, unlike Temporal.Duration.from(), would
previously drop the fractional part of numbers given to it. from() throws
if given a non-integer number, because Temporal.Duration.from('PT1.1H')
results in 1 hour, 6 minutes, but Temporal.Duration.from({ hours: 1.1 })
cannot be exact, yet should not silently drop the .1, as discussed in
issue #938.

Temporal.Duration(0, 0, 0, 0, 1.1) should now throw the same exception as
Temporal.Duration.from({ hours: 1.1 }) in order to be consistent and avoid
the surprise to users of silently dropping the .1.

Closes: #1832
@ptomato ptomato self-assigned this Oct 14, 2021
ptomato added a commit that referenced this issue Oct 14, 2021
The Temporal.Duration constructor, unlike Temporal.Duration.from(), would
previously drop the fractional part of numbers given to it. from() throws
if given a non-integer number, because Temporal.Duration.from('PT1.1H')
results in 1 hour, 6 minutes, but Temporal.Duration.from({ hours: 1.1 })
cannot be exact, yet should not silently drop the .1, as discussed in
issue #938.

Temporal.Duration(0, 0, 0, 0, 1.1) should now throw the same exception as
Temporal.Duration.from({ hours: 1.1 }) in order to be consistent and avoid
the surprise to users of silently dropping the .1.

Closes: #1832
ptomato added a commit that referenced this issue Nov 4, 2021
The Temporal.Duration constructor, unlike Temporal.Duration.from(), would
previously drop the fractional part of numbers given to it. from() throws
if given a non-integer number, because Temporal.Duration.from('PT1.1H')
results in 1 hour, 6 minutes, but Temporal.Duration.from({ hours: 1.1 })
cannot be exact, yet should not silently drop the .1, as discussed in
issue #938.

Temporal.Duration(0, 0, 0, 0, 1.1) should now throw the same exception as
Temporal.Duration.from({ hours: 1.1 }) in order to be consistent and avoid
the surprise to users of silently dropping the .1.

Closes: #1832
ptomato added a commit that referenced this issue Nov 4, 2021
The Temporal.Duration constructor, unlike Temporal.Duration.from(), would
previously drop the fractional part of numbers given to it. from() throws
if given a non-integer number, because Temporal.Duration.from('PT1.1H')
results in 1 hour, 6 minutes, but Temporal.Duration.from({ hours: 1.1 })
cannot be exact, yet should not silently drop the .1, as discussed in
issue #938.

Temporal.Duration(0, 0, 0, 0, 1.1) should now throw the same exception as
Temporal.Duration.from({ hours: 1.1 }) in order to be consistent and avoid
the surprise to users of silently dropping the .1.

Closes: #1832
ptomato added a commit that referenced this issue Nov 17, 2021
The Temporal.Duration constructor, unlike Temporal.Duration.from(), would
previously drop the fractional part of numbers given to it. from() throws
if given a non-integer number, because Temporal.Duration.from('PT1.1H')
results in 1 hour, 6 minutes, but Temporal.Duration.from({ hours: 1.1 })
cannot be exact, yet should not silently drop the .1, as discussed in
issue #938.

Temporal.Duration(0, 0, 0, 0, 1.1) should now throw the same exception as
Temporal.Duration.from({ hours: 1.1 }) in order to be consistent and avoid
the surprise to users of silently dropping the .1.

Closes: #1832
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
needs plenary input Needs to be presented to the committee and feedback incorporated spec-text Specification text involved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant