date-fns / tz

date-fns timezone utils
MIT License
80 stars 5 forks source link

Node and Chrome output different results #28

Open oaleynik opened 1 week ago

oaleynik commented 1 week ago

Hi there πŸ‘‹πŸ»

First of all - thanks for bringing timezones support to date-fns πŸ™ŒπŸ»

I'm pretty sure I missed something. However, I can't get these to work in Chrome.

// CHROME
fromUnixTime(1732204800, { in: tz('America/Denver') }).toString()
// 'Thu Nov 21 2024 18:00:00 GMT+0200 (Eastern European Standard Time)'
new TZDate(1732204800000, 'America/Denver').toString()
// 'Thu Nov 21 2024 09:00:00 GMT-0700 (Mountain Standard Time)'
format(fromUnixTime(1732204800, { in: tz('America/Denver') }), 'MM/dd/yyyy h:mm a z')
// '11/21/2024 6:00 PM GMT+2'
format(new TZDate(1732204800000, 'America/Denver'), 'MM/dd/yyyy h:mm a z')
// '11/21/2024 6:00 PM GMT+2'

Node has it as I would naturally expect:

// NODE
fromUnixTime(1732204800, { in: tz('America/Denver') }).toString()
// Thu Nov 21 2024 09:00:00 GMT-0700 (Mountain Standard Time)
new TZDate(1732204800000, 'America/Denver').toString()
// Thu Nov 21 2024 09:00:00 GMT-0700 (Mountain Standard Time)
format(fromUnixTime(1732204800, { in: tz('America/Denver') }), 'MM/dd/yyyy h:mm a z')
// 11/21/2024 9:00 AM GMT-7
format(new TZDate(1732204800000, 'America/Denver'), 'MM/dd/yyyy h:mm a z')
// 11/21/2024 9:00 AM GMT-7

Are my expectations wrong? I would expect Chrome's output to match the node's output. Thanks in advance for any hints πŸ™πŸ»

Browser: Chrome, 5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Node: v23.1.0 date-fns: 4.1.0 @date-fns/tz: 1.2.0