Skip to content

Duration.from doesn't reject some invalid strings #65

@fabon-f

Description

@fabon-f
Temporal.Duration.from('P05DT')

This code throws RangeError in Firefox Nightly, @js-temporal/polyfill and reference polyfill, but returns duration with 5 days in temporal-polyfill.

According to the spec, TimeDesignator should be followed by DurationHoursPart, DurationMinutesPart or DurationSecondsPart. Thus this polyfill is probably not spec-compliant.

https://tc39.es/proposal-temporal/#prod-DurationTime

note: it seems that test262 doesn't cover this invalid case.

https://github.com/tc39/test262/blob/main/test/built-ins/Temporal/Duration/from/argument-string-invalid.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions