MCPcopy Create free account
hub / github.com/adobe/react-spectrum / alignEnd

Function alignEnd

packages/react-stately/src/calendar/utils.ts:74–95  ·  view source on GitHub ↗
(
  date: CalendarDate,
  duration: DateDuration,
  locale: string,
  minValue?: DateValue | null,
  maxValue?: DateValue | null
)

Source from the content-addressed store, hash-verified

72}
73
74export 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
97export function constrainStart(
98 date: CalendarDate,

Callers 3

getStartDateFunction · 0.90
useCalendarStateFunction · 0.90
constrainStartFunction · 0.85

Calls 3

alignStartFunction · 0.85
constrainStartFunction · 0.85
subtractMethod · 0.45

Tested by

no test coverage detected