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

React Native: Formatting token HH does not work correctly if it is midnight #72

Open
davpons opened this issue Sep 10, 2024 · 7 comments

Comments

@davpons
Copy link

davpons commented Sep 10, 2024

format(date, "YYYY-MM-DD HH:mm")
returns 2024-09-10 0:00 instead of 2024-09-10 00:00

@justin-schroeder
Copy link
Member

what is your locale?

@davpons
Copy link
Author

davpons commented Sep 10, 2024

es

@justin-schroeder
Copy link
Member

Hmm, struggling to reproduce this:

image

Perhaps you could provide more information on your system, and maybe a video of the issue on the tempo website?

@davpons
Copy link
Author

davpons commented Sep 10, 2024

React Native app with Expo SDK 51 running on an Android device.

"@formkit/tempo": "^0.1.2",
"expo": "~51.0.28",
"react": "18.2.0",
"react-native": "0.74.5",

let dateParsed = parse("2024-09-10 00:00:00", "YYYY-MM-DD HH:mm:ss", "es"); // 2024-09-09T22:00:00.000Z
let dateFormatted = format(dateParsed, "DD-MM-YYYY HH:mm", "es"); // 10-09-2024 0:00

@davpons
Copy link
Author

davpons commented Sep 11, 2024

It seems the problem is that the JS engine included with Android is simplified and lacks many UI-focused APIs, as headless JS engines tend to be used for non-UI purposes, so there is no need to add more UI to it. Therefore, it does not have the Intl. API available.

@davpons davpons changed the title Formatting token HH does not work correctly if it is midnight React Native: Formatting token HH does not work correctly if it is midnight Sep 11, 2024
@ghiscoding
Copy link
Contributor

Perhaps this Stack Overflow might help?
React-Native and Intl polyfill required on Android device

@davpons
Copy link
Author

davpons commented Sep 21, 2024

Yes, thank you very much.

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