Open krema opened 2 weeks ago
Hi, I am running into this issue as well in version 1.1.2. Not only the toISOString() method, but also the toJSON() method formats the time not in UTC but in local TZ.
Same here. Also expected it to follow the ISO 8601 standard and that this should hold:
test("toISOString", () => {
const sg = new TZDate(2022, 2, 13, "Asia/Singapore")
const ny = sg.withTimeZone("America/New_York")
expect(
sg.toISOString()
).toBe(
ny.toISOString()
)
})
but currently results in:
+ Expected: "2022-03-12T11:00:00.000-05:00"
- Received: "2022-03-13T00:00:00.000+08:00"
The
toISOString()
method of theTZDate
class is not returning the correct output. According to the ISO 8601 standard, thetoISOString()
method should return a string in the formatYYYY-MM-DDTHH:mm:ss.sssZ
, where the timezone is always UTC, denoted by the suffixZ
.See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
Current Behavior: The method currently returns:
Please note that the format is wrong
Expected Behavior: The method should return (I'm located in 'Europe/Berlin') :
I'm using v1.1.1