Open eq0rip opened 2 years ago
I have sent a PR if someone has same issue and wants to use the solution. https://github.com/marnusw/date-fns-tz/pull/190
Having the same issue only on Android devices. I've found out that getTimezoneOffset
function returns NaN in all cases (tried with my local timezone and some other timezones).
My current package version is 1.3.4.
same, any fix?
Same here, working on iOS and in everywhere else. But on Android, it returns Date { NaN }
(Invalid Time) and crashes the app.
@luizfelipelaviola I've found a solution. In your android/app/build.gradle
just replace the line def jscFlavor = 'org.webkit:android-jsc:+'
with def jscFlavor = 'org.webkit:android-jsc-intl:+'
and it works. There was an issue with Android build system.
You can find more details here.
@luizfelipelaviola I've found a solution. In your
android/app/build.gradle
just replace the linedef jscFlavor = 'org.webkit:android-jsc:+'
withdef jscFlavor = 'org.webkit:android-jsc-intl:+'
and it works. There was an issue with Android build system. You can find more details here.
Thanks for sharing that... But this is not working with Hermes. I found the updated documentation for date-fns-tz https://github.com/marnusw/date-fns-tz#usage-with-android Time to move on to another solution...
@luizfelipelaviola @dimakruhlyi @dmytrokruhlyi
have you tried my PR https://github.com/marnusw/date-fns-tz/pull/190
?
it's sorted on my side with this workaround
I'm using RN v0.66.3 for Android with Hermes. I tried the #190 from @eq0rip and editing the build.gradle
as @dimakruhlyi said but both didn't work.
The solution was follow the @marnusw recommendation and start using polyfills by Format.JS on the date-fns-tz docs.
I've installed and added all polyfills and dependencies from Format.JS and everything is working very well right now.
Just install and put this on the top of your main index.tsx
file:
import '@formatjs/intl-locale/polyfill'
import '@formatjs/intl-getcanonicallocales/polyfill'
import '@formatjs/intl-pluralrules/polyfill'
import '@formatjs/intl-pluralrules/locale-data/en'
import '@formatjs/intl-numberformat/polyfill'
import '@formatjs/intl-numberformat/locale-data/en'
import '@formatjs/intl-datetimeformat/polyfill'
import '@formatjs/intl-datetimeformat/locale-data/en'
Hope that helps someone else.
While the library is working well on most parts. We recently started seeing error report on Sentry
Invalid time value
on some of the Android 6 devices. But we were concerned when recently we had the same case reported onAndroid 12
device too. We debugged on emulater forandroid 6
and were able to recreate the error and turns ourtzTokenizeDate
is returningmonthName
instead ofmonthNumber
.