* 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)
| 92 | * the following day. |
| 93 | */ |
| 94 | function 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 |
no test coverage detected