date-fns-tz
date-fns-tz copied to clipboard
Any way to remove dependency to New_York timezone data
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.
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'
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.
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+.