MCPcopy Index your code
hub / github.com/plotly/dash / strAsDate

Function strAsDate

components/dash-core-components/src/utils/calendar/helpers.ts:94–115  ·  view source on GitHub ↗
(
    dateStr?: string,
    formatStr?: string
)

Source from the content-addressed store, hash-verified

92}
93
94export function strAsDate(
95 dateStr?: string,
96 formatStr?: string
97): Date | undefined {
98 if (!dateStr) {
99 return undefined;
100 }
101
102 const locale = getUserLocale();
103 let parsed = formatStr
104 ? parse(dateStr, convertFormatTokens(formatStr), new Date(), {
105 locale,
106 })
107 : parseISO(dateStr);
108
109 // Fallback to native Date constructor for non-ISO formats
110 if (!isValid(parsed)) {
111 parsed = new Date(dateStr);
112 }
113
114 return isValid(parsed) ? startOfDay(parsed) : undefined;
115}
116
117type AnyDayFormat = string | Date | DatePickerSingleProps['date'];
118export function isSameDay(day1?: AnyDayFormat, day2?: AnyDayFormat): boolean {

Callers 4

DatePickerRangeFunction · 0.90
DatePickerSingleFunction · 0.90
helpers.test.tsFile · 0.90
isSameDayFunction · 0.85

Calls 2

getUserLocaleFunction · 0.85
convertFormatTokensFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…