formkit / tempo

📆 Parse, format, manipulate, and internationalize dates and times in JavaScript and TypeScript.
https://tempo.formkit.com
MIT License
2.37k stars 33 forks source link

Incorrect GMT offset when using FormatOptions with timezone #14

Closed ztamas83 closed 9 months ago

ztamas83 commented 9 months ago

The following code will result in wrong time display. The input is in UTC/Zulu time. The timezone shift occurs but the offset is not maintained and presented in the format.

format({
    date: new Date('2024-02-16T11:00:00Z'),
    format: 'YYYY-MM-DDTHH:mm:ssZ',
    tz: "Europe/Stockholm"
})

Result: 2024-02-16T12:00:00+0000

justin-schroeder commented 9 months ago

This is true — the TZ does not survive the output. As a work around it can be appended for now, but I think this is a feature we can/should add.

justin-schroeder commented 9 months ago

@ztamas83 ok, this should be now be fixed in 0.0.10. Thanks for pointing it out