Skip to content

Polyfill: ParseISODateTime(isoString, { zoneRequired: true }) doesn't actually require a zone. Expected? #1973

@justingrant

Description

@justingrant

While investigating TS errors in temporal-polyfill, I noticed that proposal-temporal polyfill's implementation of ParseISODateTime adds a zoneRequired option. (It's not in the spec, this is just in the polyfill.) What is this option used for?

I'm asking because strings that have no time zone nor offset will still return a successful match from that function, albeit with the timezone and offset fields undefined. Is this expected? If yes, then what's the purpose of that option?

Repro:

zoneRequiredRegex = new RegExp('^((?:[+\\u2212-]\\d{6}|\\d{4}))(?:-((?:0[1-9]|1[0-2]))-((?:0[1-9]|[12]\\d|3[01]))|((?:0[1-9]|1[0-2]))((?:0[1-9]|[12]\\d|3[01])))(?:(?:T|\\s+)(\\d{2})(?::(\\d{2})(?::(\\d{2})(?:[.,](\\d{1,9}))?)?|(\\d{2})(?:(\\d{2})(?:[.,](\\d{1,9}))?)?)?)?(?:([zZ])|(?:([+\\u2212-])([01][0-9]|2[0-3])(?::?([0-5][0-9])(?::?([0-5][0-9])(?:[.,](\\d{1,9}))?)?)?)?)(?:\\[((?:(?:\\.[-A-Za-z_]|\\.\\.[-A-Za-z._]{1,12}|\\.[-A-Za-z_][-A-Za-z._]{0,12}|[A-Za-z_][-A-Za-z._]{0,13})(?:\\/(?:\\.[-A-Za-z_]|\\.\\.[-A-Za-z._]{1,12}|\\.[-A-Za-z_][-A-Za-z._]{0,12}|[A-Za-z_][-A-Za-z._]{0,13}))*|Etc\\/GMT[-+]\\d{1,2}|(?:[+\\u2212-][0-2][0-9](?::?[0-5][0-9](?::?[0-5][0-9](?:[.,]\\d{1,9})?)?)?)))\\])?(?:\\[u-ca=((?:[A-Za-z0-9]{3,8}(?:-[A-Za-z0-9]{3,8})*))\\])?$', 'i');
zoneRequiredRegex.test('2021-08-19T17:30');
// => true

Metadata

Metadata

Assignees

No one assigned

    Labels

    no-spec-textPR can be ignored by implementorsnon-prod-polyfillTHIS POLYFILL IS NOT FOR PRODUCTION USE!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions