react-spectrum
react-spectrum copied to clipboard
fromAbsolute in @internalization/date parses dates BC incorrectly
Provide a general summary of the issue here
When using fromAbsolute on a number less then -62135596800000
(0001-01-01T00:00:00Z
) results in the correct date and time except the year is always 0001 AD.
๐ค Expected Behavior?
When using the absolute value -62135596800001
i would expect the date to be 0000-12-31T23:59:59.999Z
.
๐ฏ Current Behavior
Currently -62135596800001
results in 0001-12-31T23:59:59.999Z
๐ Possible Solution
Replacing the return value in the fromAbsolute function with:
return new ZonedDateTime(year < 1 ? "BC" : "AD", year < 0 ? Math.abs(year) + 1 : year, month, day, timeZone, offset, hour, minute, second, millisecond);
๐ฆ Context
No response
๐ฅ๏ธ Steps to Reproduce
import { fromAbsolute } from "@internationalized/date";
console.log(fromAbsolute(-62135596800000, "UTC").toAbsoluteString()); console.log(fromAbsolute(-62135596800001, "UTC").toAbsoluteString());
Version
3.5.4 (@internationalized/date)
What browsers are you seeing the problem on?
Chrome, Microsoft Edge
If other, please specify.
No response
What operating system are you using?
Windows
๐งข Your Company/Team
No response
๐ท Tracking Issue
No response