( date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue | null, maxValue?: DateValue | null )
| 52 | } |
| 53 | |
| 54 | export function alignStart( |
| 55 | date: CalendarDate, |
| 56 | duration: DateDuration, |
| 57 | locale: string, |
| 58 | minValue?: DateValue | null, |
| 59 | maxValue?: DateValue | null |
| 60 | ): CalendarDate { |
| 61 | // align to the start of the largest unit |
| 62 | let aligned = date; |
| 63 | if (duration.years) { |
| 64 | aligned = startOfYear(date); |
| 65 | } else if (duration.months) { |
| 66 | aligned = startOfMonth(date); |
| 67 | } else if (duration.weeks || (duration.days && duration.days > 7)) { |
| 68 | aligned = startOfWeek(date, locale); |
| 69 | } |
| 70 | |
| 71 | return constrainStart(date, aligned, duration, locale, minValue, maxValue); |
| 72 | } |
| 73 | |
| 74 | export function alignEnd( |
| 75 | date: CalendarDate, |
no test coverage detected