Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Timezone in ISO string not parsed properly #1688

Closed
@ThomasRinsma

Description

@ThomasRinsma

Describe the bug
When usingfromISO on an string with a timezone in square brackets, a parsing issue is revealed. Specifically, a JavaScript/TypeScript look-up object is used somewhere down the line which uses a regular Object, instead of one with a null-prototype. This means that default Object keys are considered valid, and hence, for example,constructor is (partially) considered a valid timezone:

(pseudocode of likely implementation)

varlookup={};if(lookup["constructor"]){ ...}// true

Luckily, later logic seems to fail on these keys, so the only impact appears to be a somewhat confusing error message:

>luxon.DateTime.fromISO("2020-01-01T11:22:33+01:00[constructor]")DateTime{ts:1742121941768,_zone:SystemZone{},loc:Locale{locale:'en-US',numberingSystem:null,outputCalendar:null,intl:'en-US',weekdaysCache:{format:{},standalone:{}},monthsCache:{format:{},standalone:{}},meridiemCache:null,eraCache:{},specifiedLocale:null,fastNumbersCached:null},invalid:Invalid{reason:'unsupported zone',explanation:'the zone "function Object() { [native code] }" is not supported'},weekData:null,c:null,o:null,isLuxonDateTime:true}

To Reproduce

varluxon=require("luxon");console.log(luxon.DateTime.fromISO("2020-01-01T11:22:33+01:00[constructor]"));

Actual vs Expected behavior
The result'sinvalid.explanation shows:

'the zone "function Object() { [native code] }" is not supported'

while we'd expect:

'the zone "constructor" is not supported'

Desktop (please complete the following information):

  • OS: Linux
  • Browser: Node
  • Luxon version: 3.5.0
  • Your timezone:constructor ;)

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp