MCPcopy Create free account
hub / github.com/coder/coder / toBoundary

Function toBoundary

site/src/components/DateRangePicker/DateRangePicker.tsx:94–101  ·  view source on GitHub ↗

* Normalise a calendar selection into the API-friendly boundary format * that the old component produced: startDate at midnight, endDate either * rounded up to the next hour (if it falls on today) or to the start of * the following day.

(from: Date, to: Date, now: Date)

Source from the content-addressed store, hash-verified

92 * the following day.
93 */
94function toBoundary(from: Date, to: Date, now: Date): DateRangeValue {
95 const currentTime = dayjs(now);
96 const start = dayjs(from).startOf("day").toDate();
97 const end = dayjs(to).isSame(currentTime, "day")
98 ? currentTime.startOf("hour").add(1, "hour").toDate()
99 : dayjs(to).startOf("day").add(1, "day").toDate();
100 return { startDate: start, endDate: end };
101}
102
103/**
104 * Reverse the boundary normalization so the calendar highlights the

Callers 2

commitFunction · 0.85
handlePresetFunction · 0.85

Calls 1

addMethod · 0.45

Tested by

no test coverage detected