MCPcopy Index your code
hub / github.com/simstudioai/sim / formatDateRangeLabel

Function formatDateRangeLabel

packages/emcn/src/components/calendar/calendar.tsx:82–104  ·  view source on GitHub ↗
(
  start: string | Date | undefined,
  end: string | Date | undefined
)

Source from the content-addressed store, hash-verified

80 * to a placeholder.
81 */
82export function formatDateRangeLabel(
83 start: string | Date | undefined,
84 end: string | Date | undefined
85): string {
86 const startDate = parseDateValue(start)
87 const endDate = parseDateValue(end)
88 if (!startDate && !endDate) return ''
89 if (startDate && !endDate) return formatDateLabel(startDate)
90 if (!startDate && endDate) return formatDateLabel(endDate)
91 if (!startDate || !endDate) return ''
92 const sameYear = startDate.getFullYear() === endDate.getFullYear()
93 const startLabel = startDate.toLocaleDateString('en-US', {
94 month: 'short',
95 day: 'numeric',
96 ...(sameYear ? {} : { year: 'numeric' }),
97 })
98 const endLabel = endDate.toLocaleDateString('en-US', {
99 year: 'numeric',
100 month: 'short',
101 day: 'numeric',
102 })
103 return `${startLabel} - ${endLabel}`
104}
105
106function isSameDay(a: Date, b: Date): boolean {
107 return (

Callers 2

calendar.test.tsFile · 0.90

Calls 2

formatDateLabelFunction · 0.85
parseDateValueFunction · 0.70

Tested by

no test coverage detected