MCPcopy Create free account
hub / github.com/simstudioai/sim / buildRangeBounds

Function buildRangeBounds

packages/emcn/src/components/calendar/calendar.tsx:132–158  ·  view source on GitHub ↗
(
  start: Date,
  end: Date,
  options: { showTime: boolean; startTime: string; endTime: string }
)

Source from the content-addressed store, hash-verified

130 * times are swapped when inverted so the range never ends before it starts.
131 */
132export function buildRangeBounds(
133 start: Date,
134 end: Date,
135 options: { showTime: boolean; startTime: string; endTime: string }
136): { start: string; end: string } {
137 const ordered = end < start ? { start: end, end: start } : { start, end }
138 const startStr = toDateString(
139 ordered.start.getFullYear(),
140 ordered.start.getMonth(),
141 ordered.start.getDate()
142 )
143 const endStr = toDateString(
144 ordered.end.getFullYear(),
145 ordered.end.getMonth(),
146 ordered.end.getDate()
147 )
148
149 if (!options.showTime) return { start: startStr, end: endStr }
150
151 let startTime = options.startTime
152 let endTime = options.endTime
153 if (startStr === endStr && startTime > endTime) {
154 startTime = options.endTime
155 endTime = options.startTime
156 }
157 return { start: `${startStr}T${startTime}`, end: `${endStr}T${endTime}:59` }
158}
159
160interface CalendarBaseProps {
161 /** Forwarded to the root grid container. */

Callers 2

calendar.test.tsFile · 0.90
applyFunction · 0.85

Calls 1

toDateStringFunction · 0.85

Tested by

no test coverage detected