Support Temporal type in @internationalized/date DateFormatter
- Dominant language
- TypeScript
- Stars
- 15.9k
- Forks
- 1.6k
- Avg merge
- 3d 9m
- Merged PRs (30d)
- 59
Description
### Provide a general summary of the feature here
Currently, DateFormatter.format in @internationalized/date only supports `Date` as an input:
https://github.com/adobe/react-spectrum/blob/8e585dfb43252fd53a208d01f1e5ec584084248b/packages/%40internationalized/date/src/DateFormatter.ts#L30-L36
In TypeScript lib ESNext, Intl.DateTimeFormat.format supports the Temporal classes: https://github.com/microsoft/TypeScript/blob/f350b52331494b68c90ab02e2b6d0828d2a22a74/src/lib/esnext.intl.d.ts#L4-L11
### 🤔 Expected Behavior?
I think it would be nice to support Temporal. When I tried, DateFormatter still worked as expected when typecast `as unknown as Date`.
### 😯 Current Behavior
Currently, it throws a type error due to Date and Temporal being different classes.
### 💁 Possible Solution
Something like this:
```
type Formattable = Parameters[0]
```
Would allow different formatted dates based on the current overloads (although it does allow number, which may not be intended)
### 🔦 Context
I am using Temporal along @internationalized/date. ZonedDateTime in Temporal can be used with arbitrary UTC offsets instead of only those represented in IANA time zone; my app uses [Exif data based on timezone offsets](https://en.wikipedia.org/wiki/Exif#Time_tags) and doesn't have access to the timezone.
### 💻 Examples
_No response_
### 🧢 Your Company/Team
_No response_
### 🕷 Tracking Issue
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.