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

DateTime.fromISO behaviour inconsistent with docs #1531

Open
onlyskin opened this issue Oct 27, 2023 · 0 comments
Open

DateTime.fromISO behaviour inconsistent with docs #1531

onlyskin opened this issue Oct 27, 2023 · 0 comments

Comments

@onlyskin
Copy link

Describe the bug
Constructing a DateTime instance from a zoned ISO string creates a DateTime instance with the local timezone not with the timezone from the string.

To Reproduce
DateTime.fromISO('2016-05-25T09:00:00.000+06:00').zone.name will log your local timezone name, not the +06:00
DateTime.fromISO('2016-05-25T09:00:00.000+06:00', {zone: 'UTC+6'}).zone.name will log the correct timezone offset

same thing happens if you set the ISO string timezone to UTC or a geographical zone

Actual vs Expected behavior
The docs for the DateTime.fromISO method state for opts.zone: "use this zone if no offset is specified in the input string itself. Will also convert the time to this zone". This implied to me that if I did not specify the opts.zone it would return a DateTime instance zoned to match the ISO string and caused some confusion. Would be better to say something like "Specify a zone for the DateTime instance. If the input string does not specify a timezone, parse it as a local time in the opts.zone offset."

I think it would be sufficient to update the documentation to make it clear this is the behaviour.

Desktop (please complete the following information):

  • OS: macos
  • Browser: Chrome Version 117.0.5938.149 (Official Build) (x86_64)
  • version luxon@3.4.3
  • Your timezone 'Europe/Athens'
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