Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formatToTimeZone depends unexpectedly on system timezone #20

Open
alexandercurtis opened this issue Mar 26, 2020 · 0 comments
Open

formatToTimeZone depends unexpectedly on system timezone #20

alexandercurtis opened this issue Mar 26, 2020 · 0 comments

Comments

@alexandercurtis
Copy link

Using formatToTimeZone to convert an absolute time value to a date/time localised to a timezone gives different results depending on system timezone.

When converting an absolute number of milliseconds since epoch into an arbitrary timezone, I would not expect the local timezone to have any effect.

For example, compare system timezone as Europe/London:

$ TZ=Europe/London node
> const {formatToTimeZone} = require('date-fns-timezone');
undefined
> formatToTimeZone( 1585422000000, 'YYYY-MM-DDTHH:mm:ssZ', {timeZone: 'Pacific/Auckland'})
'2020-03-29T09:00:00+13:00'

with system timezone America/New_York:

$ TZ=America/New_York node
> const {formatToTimeZone} = require('date-fns-timezone');
undefined
> formatToTimeZone( 1585422000000, 'YYYY-MM-DDTHH:mm:ssZ', {timeZone: 'Pacific/Auckland'})
'2020-03-29T08:00:00+13:00'

The hour part is different : 09 vs 08

According to [1] the correct value is 08.

[1] https://www.epochconverter.com/timezones?q=1585422000000&tz=Pacific%2FAuckland

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant