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

setZone('America/New_York') producing 'Invalid DateTime' on ReactNative 0.59 (Android) #541

Closed
bramski opened this issue Jul 11, 2019 · 8 comments

Comments

@bramski
Copy link

bramski commented Jul 11, 2019

Version: 1.8.2
ReactNative: 0.59
Platform: Android

Trying to dig deeper...
The following code: DateTime.fromISO('2020-09-17T16:00:00-04:00') returns Invalid DateTime. Not sure if something changes in the javascript runtime or something...

@bramski bramski changed the title DateTime.fromISO failing to parse ISO date strings on ReactNative 0.59 DateTime.fromISO failing to parse ISO date strings on ReactNative 0.59 (Android) Jul 11, 2019
@icambron
Copy link
Member

That is pretty weird. Unfortunately I have no idea. Can you check invalidReason and invalidExplanation on that invalid instance?

@bramski
Copy link
Author

bramski commented Jul 11, 2019

I'm baffled as well... If I do the following:
import { parseISODate } from 'luxon/src/impl/regexParser';
and then parseISODate('2020-09-17T16:00:00-04:00') I get back the date parts.

@icambron
Copy link
Member

Do you have any settings overrides, particularly defaultZone?

@bramski bramski changed the title DateTime.fromISO failing to parse ISO date strings on ReactNative 0.59 (Android) toFormat producing 'Invalid DateTime' on ReactNative 0.59 (Android) Jul 11, 2019
@bramski
Copy link
Author

bramski commented Jul 11, 2019

No settings overrides.
Dug a bit deeper this morning (we have a side library that takes dates and produces standard time strings for us from our API)
It seems that DateTime.fromISO is actually succeeding, but calling toFormat('h:mm a ZZZ') is causing the 'Invalid DateTime' to be returned.

@bramski
Copy link
Author

bramski commented Jul 11, 2019

Ah wait... it seems like there is an additional call in here that is failing:
setZone('America/New_York') is returning null and that is causing the toFormat to return an invalid datetime.

@bramski bramski changed the title toFormat producing 'Invalid DateTime' on ReactNative 0.59 (Android) setZone('America/New_York') producing 'Invalid DateTime' on ReactNative 0.59 (Android) Jul 11, 2019
@bramski
Copy link
Author

bramski commented Jul 11, 2019

So it seems this isn't Luxon's issue, but Intl no longer accepts 'America/New_York' as a valid timezone on the latest upgrade of React-Native.

@bramski
Copy link
Author

bramski commented Jul 11, 2019

Solved by: andyearnshaw/Intl.js#19
You need the JSC intl support: https://github.com/react-native-community/jsc-android-buildscripts#international-variant
Also don't be a stupid and install the intl polyfill on react-native or you're in for a world of hurt (or your predecessor).
Fixes this.

@bramski bramski closed this as completed Jul 11, 2019
@santiagofm
Copy link

Thank you @bramski for the thorough investigation! 🥇

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