MCPcopy
hub / github.com/simstudioai/sim / parseDateValue

Function parseDateValue

packages/emcn/src/components/calendar/calendar.tsx:56–65  ·  view source on GitHub ↗
(value: string | Date | undefined)

Source from the content-addressed store, hash-verified

54 * (UTC midnight) produces in negative-offset timezones.
55 */
56export function parseDateValue(value: string | Date | undefined): Date | null {
57 if (!value) return null
58 if (value instanceof Date) return Number.isNaN(value.getTime()) ? null : value
59 if (/^\d{4}-\d{2}-\d{2}/.test(value)) {
60 const [year, month, day] = value.slice(0, 10).split('-').map(Number)
61 return new Date(year, month - 1, day)
62 }
63 const parsed = new Date(value)
64 return Number.isNaN(parsed.getTime()) ? null : parsed
65}
66
67/**
68 * Human-readable label for a date value (e.g. `May 8, 2026`). Returns an empty

Callers 5

calendar.test.tsFile · 0.90
formatDateLabelFunction · 0.70
formatDateRangeLabelFunction · 0.70
SingleCalendarViewFunction · 0.70
RangeCalendarViewFunction · 0.70

Calls 1

testMethod · 0.80

Tested by

no test coverage detected