tempo icon indicating copy to clipboard operation
tempo copied to clipboard

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

Open davpons opened this issue 1 year ago • 7 comments

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

davpons avatar Sep 10 '24 19:09 davpons

what is your locale?

justin-schroeder avatar Sep 10 '24 19:09 justin-schroeder

es

davpons avatar Sep 10 '24 19:09 davpons

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?

justin-schroeder avatar Sep 10 '24 19:09 justin-schroeder

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 avatar Sep 10 '24 20:09 davpons

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 avatar Sep 11 '24 05:09 davpons

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

ghiscoding avatar Sep 21 '24 04:09 ghiscoding

Yes, thank you very much.

davpons avatar Sep 21 '24 08:09 davpons