date-fns-tz icon indicating copy to clipboard operation
date-fns-tz copied to clipboard

Any way to remove dependency to New_York timezone data

Open mistic100 opened this issue 4 years ago • 3 comments

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 avatar May 06 '20 10:05 mistic100

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'

mistic100 avatar May 06 '20 10:05 mistic100

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.

windmaomao avatar May 21 '20 14:05 windmaomao

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+.

mediafreakch avatar Oct 06 '20 10:10 mediafreakch