marnusw / date-fns-tz

Complementary library for date-fns v2 adding IANA time zone support
MIT License
1.06k stars 116 forks source link

Support for UTC offsets #98

Open osdiab opened 3 years ago

osdiab commented 3 years ago

Out of the box, luxon supports specifying a time zone offset like UTC+9 or UTC-3, but that's not part of the IANA timezone names database so it seems using those with date-fns-tz throws an error instead. Would be nice to include some logic to handle that parsing, but makes sense if beyond the scope of this.

marnusw commented 3 years ago

I'd be happy for this library to support anything Luxon does because we share the same sentiment and this implementation derived from that project originally. I'll add it if I find time, or please create a PR if your need is pressing enough.

raphaelschaad commented 3 years ago

Would this issue solely cover parsing "UTC[+<OFFSET>]" offsets, or also formatting, e.g. output:

format(parisDate, 'yyyy-MM-dd HH:mm:ss zzz', { timeZone: 'Europe/Paris' }) // 2014-10-25 10:46:20 UTC+2

Instead of (currently):

format(parisDate, 'yyyy-MM-dd HH:mm:ss zzz', { timeZone: 'Europe/Paris' }) // 2014-10-25 10:46:20 GMT+2

Would using UTC over GMT in this case even be "correct"?