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

Any way to remove dependency to New_York timezone data #68

Open
mistic100 opened this issue May 6, 2020 · 3 comments
Open

Any way to remove dependency to New_York timezone data #68

mistic100 opened this issue May 6, 2020 · 3 comments

Comments

@mistic100
Copy link

In order to fix #38 (works really well BTW) the lib now needs the timezone data for America/New_York because of this
https://github.com/marnusw/date-fns-tz/blob/master/src/_lib/tzTokenizeDate/index.js#L49

In my application I include the bare minimum to make this work on IE11 :

import 'date-time-format-timezone/build/browserified/date-time-format-timezone-no-data';
import 'date-time-format-timezone/build/browserified/data/metazone';
import 'date-time-format-timezone/build/browserified/data/timezones/tzdata-europe-paris';
// some other french zones...

And I am now required to include "tzdata-america-new_york" as well.

I wonder if there is way to make the test of Intl.DateTimeFormat API version without depending on any timezone.

@mistic100
Copy link
Author

mistic100 commented May 6, 2020

From my quick test the test can be executed in UTC as well

 var testDateFormatted = new Intl.DateTimeFormat('en-US', {
      hour12: false,
      timeZone: 'UTC',
      year: 'numeric',
      month: '2-digit',
      day: '2-digit',
      hour: '2-digit',
      minute: '2-digit',
      second: '2-digit'
    }).format(new Date('2014-06-25T00:00:00.123Z'))
    var hourCycleSupported =
      testDateFormatted === '06/25/2014, 00:00:00' ||
      testDateFormatted === '‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00'

@windmaomao
Copy link

this is very weird, couldn't get this working under IE11 and I don't know why a specific timezone will be a dependency. Currently the IE11 does return the "correct" timezone which is null.

@mediafreakch
Copy link
Contributor

mediafreakch commented Oct 6, 2020

My issue seems related to this. We are using date-fns-tz in production and saw issues in Firefox 48 (on Mac OSX 10.7) with Sentry.io. Also in IE11, but that was kind of expected as we didn't aim for compatibility.

The logged error when calling utcToZonedTime is:

invalid time zone in DateTimeFormat(): AMERICA/NEW_YORK

As a side note: The timeZone passed to utcToZonedTime is not AMERICA/NEW_YORK!
I can't reproduce the issue manually though...

UPDATE:

I was able to reproduce. FF 48 is outdated. The issue doesn't appear with FF 52+.

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

3 participants