Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Timezone in ISO string not parsed properly #1688

Open
ThomasRinsma opened this issue Mar 16, 2025 · 0 comments
Open

Timezone in ISO string not parsed properly #1688

ThomasRinsma opened this issue Mar 16, 2025 · 0 comments

Comments

@ThomasRinsma
Copy link

Describe the bug
When using fromISO 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)

var lookup = {};
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

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

Actual vs Expected behavior
The result's invalid.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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant