(
start: Date,
end: Date,
options: { showTime: boolean; startTime: string; endTime: string }
)
| 130 | * times are swapped when inverted so the range never ends before it starts. |
| 131 | */ |
| 132 | export 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 | |
| 160 | interface CalendarBaseProps { |
| 161 | /** Forwarded to the root grid container. */ |
no test coverage detected