moment / luxon

⏱ A library for working with dates and times in JS
https://moment.github.io/luxon
MIT License
15.4k stars 729 forks source link

fromISO() => toJSDate() not preserving the timezone information #1305

Closed eliashdezr closed 1 year ago

eliashdezr commented 2 years ago

Describe the bug Parsing a ISO string with timezone information is not preserved in the toJSDate() function

To Reproduce

const originalIso = "2022-10-18T15:00:00.000-04:00";
const jsDate = DateTime.fromISO(originalIso)
  .setZone("America/New_York")
  .toJSDate();
const jsDateNoSetZone = DateTime.fromISO(originalIso).toJSDate();

Actual vs Expected behavior Actual Tue Oct 18 2022 14:00:00 GMT-0500 (Central Daylight Time)

Expected Tue Oct 18 2022 15:00:00 GMT-0400 (Eastern Time)

https://codesandbox.io/s/determined-ptolemy-lfmxih?file=/src/index.js:496-553

Desktop (please complete the following information):

icambron commented 2 years ago

The native date type doesn't support time zones

icambron commented 1 year ago

Closing bc age. This is more of a misunderstanding about the native date than it is a Luxon issue.