( date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue | null, maxValue?: DateValue | null )
| 72 | } |
| 73 | |
| 74 | export function alignEnd( |
| 75 | date: CalendarDate, |
| 76 | duration: DateDuration, |
| 77 | locale: string, |
| 78 | minValue?: DateValue | null, |
| 79 | maxValue?: DateValue | null |
| 80 | ): CalendarDate { |
| 81 | let d = {...duration}; |
| 82 | // subtract 1 from the smallest unit |
| 83 | if (d.days) { |
| 84 | d.days--; |
| 85 | } else if (d.weeks) { |
| 86 | d.weeks--; |
| 87 | } else if (d.months) { |
| 88 | d.months--; |
| 89 | } else if (d.years) { |
| 90 | d.years--; |
| 91 | } |
| 92 | |
| 93 | let aligned = alignStart(date, duration, locale).subtract(d); |
| 94 | return constrainStart(date, aligned, duration, locale, minValue, maxValue); |
| 95 | } |
| 96 | |
| 97 | export function constrainStart( |
| 98 | date: CalendarDate, |
no test coverage detected