( date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue | null, maxValue?: DateValue | null )
| 33 | } |
| 34 | |
| 35 | export function alignCenter( |
| 36 | date: CalendarDate, |
| 37 | duration: DateDuration, |
| 38 | locale: string, |
| 39 | minValue?: DateValue | null, |
| 40 | maxValue?: DateValue | null |
| 41 | ): CalendarDate { |
| 42 | let halfDuration: DateDuration = {}; |
| 43 | for (let key in duration) { |
| 44 | halfDuration[key] = Math.floor(duration[key] / 2); |
| 45 | if (halfDuration[key] > 0 && duration[key] % 2 === 0) { |
| 46 | halfDuration[key]--; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | let aligned = alignStart(date, duration, locale).subtract(halfDuration); |
| 51 | return constrainStart(date, aligned, duration, locale, minValue, maxValue); |
| 52 | } |
| 53 | |
| 54 | export function alignStart( |
| 55 | date: CalendarDate, |
no test coverage detected