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 ReproduceDateTime.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)
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:00DateTime.fromISO('2016-05-25T09:00:00.000+06:00', {zone: 'UTC+6'}).zone.name
will log the correct timezone offsetsame 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 theopts.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):