Open
Description
Bug Description
For very old dates, such as "0004-04-13T00:00:00Z", the .toLocaleString() will make the date string off by two days. i.e. it will be April 15 instead of April 13.
- I have run
gradle clean
and confirmed this bug does not occur with JSC - The issue is reproducible with the latest version of React Native.
Hermes git revision (if applicable):
React Native version: 0.76
OS: iOS and Android
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): all
Steps To Reproduce
Go to https://reactnative.dev/docs/tutorial.
Paste the following:
import React from 'react';
import {Text, View} from 'react-native';
const HelloWorldApp = () => {
const isoDate = "0004-04-13T00:00:00Z";
const date = new Date(isoDate);
let formatOptions: Intl.DateTimeFormatOptions = {
month: "numeric",
day: "numeric",
};
const dateString = date.toLocaleString("en-US", formatOptions);
return (
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
}}>
<Text>{dateString}</Text>
</View>
);
};
export default HelloWorldApp;
Switch to Android or iOS.
The Expected Behavior
Date should be 4/13.
Instead its 4/15.
Activity