MCPcopy Create free account
hub / github.com/adobe/react-spectrum / convertDateTime

Function convertDateTime

packages/@react-spectrum/s2/src/LabeledValue.tsx:313–322  ·  view source on GitHub ↗
(value: DateTime, timeZone: string)

Source from the content-addressed store, hash-verified

311}
312
313function convertDateTime(value: DateTime, timeZone: string): Date {
314 if ('timeZone' in value) {
315 return (value as ZonedDateTime).toDate();
316 } else if ('calendar' in value) {
317 return (value as CalendarDate | CalendarDateTime).toDate(timeZone);
318 } else if (!(value instanceof Date)) {
319 return toCalendarDateTime(today(getLocalTimeZone()), value as Time).toDate(timeZone);
320 }
321 return value;
322}
323
324function getDefaultFormatOptions(value: DateTime): Intl.DateTimeFormatOptions {
325 if (value instanceof Date) {

Callers 1

FormattedDateFunction · 0.70

Calls 4

toCalendarDateTimeFunction · 0.90
todayFunction · 0.90
getLocalTimeZoneFunction · 0.90
toDateMethod · 0.45

Tested by

no test coverage detected