Provide a general summary of the feature here
Currently, DateFormatter.format in @internationalized/date only supports Date as an input:
|
/** |
|
* Formats a date as a string according to the locale and format options passed to the |
|
* constructor. |
|
*/ |
|
format(value: Date): string { |
|
return this.formatter.format(value); |
|
} |
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<Intl.DateTimeFormat["format"]>[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 and doesn't have access to the timezone.
💻 Examples
No response
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response
Provide a general summary of the feature here
Currently, DateFormatter.format in @internationalized/date only supports
Dateas an input:react-spectrum/packages/@internationalized/date/src/DateFormatter.ts
Lines 30 to 36 in 8e585df
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:
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 and doesn't have access to the timezone.
💻 Examples
No response
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response