# plain/calculate

Industry: Core

- [`addBusinessDays`](/gmt/reference/plain/calculate/addBusinessDays/): Return a PlainDate ISO string with `amount` working days added to `value`.
- [`addDate`](/gmt/reference/plain/calculate/addDate/): Return a PlainDate ISO string with `amount` added according to `units`.
- [`addDateTime`](/gmt/reference/plain/calculate/addDateTime/): Return a PlainDateTime ISO string with `units` added to `value`.
- [`addTime`](/gmt/reference/plain/calculate/addTime/): Return a PlainTime ISO string with `units` added to `value`.
- [`addYearMonth`](/gmt/reference/plain/calculate/addYearMonth/): Return a year-month string moved forward by `units`.
- [`clampDate`](/gmt/reference/plain/calculate/clampDate/): Restrict `value` to the range [`min`, `max`].
- [`closestDateTo`](/gmt/reference/plain/calculate/closestDateTo/): Return the candidate date nearest to `target` by calendar distance.
- [`cycleDate`](/gmt/reference/plain/calculate/cycleDate/): Return a PlainDate ISO string with `field` cycled by `amount`, wrapping at that field's own min/max instead of carrying into the next larger field.
- [`cycleDateTime`](/gmt/reference/plain/calculate/cycleDateTime/): Return a PlainDateTime ISO string with `field` cycled by `amount`, wrapping at that field's own min/max instead of carrying into the next larger field.
- [`cycleTime`](/gmt/reference/plain/calculate/cycleTime/): Return a PlainTime ISO string with `field` cycled by `amount`, wrapping at that field's own min/max instead of carrying into the next larger field (`hour` 23 `+1` wraps to `0`, it never changes a date — `cycleTime` has no date component to carry into in the first place).
- [`diffDate`](/gmt/reference/plain/calculate/diffDate/): Return the difference between two PlainDate values using the provided `unit`.
- [`diffDateAsDuration`](/gmt/reference/plain/calculate/diffDateAsDuration/): Return the difference between two PlainDate values as an ISO 8601 duration string, bridging to the `duration` namespace (see `parseDuration`, `normalizeDuration`).
- [`diffDateTime`](/gmt/reference/plain/calculate/diffDateTime/): Return the difference between two PlainDateTime values in the requested unit.
- [`diffDateTimeAsDuration`](/gmt/reference/plain/calculate/diffDateTimeAsDuration/): Return the difference between two PlainDateTime values as an ISO 8601 duration string, bridging to the `duration` namespace (see `parseDuration`, `normalizeDuration`).
- [`diffTime`](/gmt/reference/plain/calculate/diffTime/): Return the difference between two PlainTime values in the requested unit.
- [`diffYearMonth`](/gmt/reference/plain/calculate/diffYearMonth/): Return the whole years or months from year-month `a` to year-month `b`.
- [`endOfDate`](/gmt/reference/plain/calculate/endOfDate/): Return the end of the specified date `unit` for a given ISO 8601 date string.
- [`endOfDateTime`](/gmt/reference/plain/calculate/endOfDateTime/): Return the end of the specified date-time `unit` for a given ISO 8601 datetime string.
- [`endOfQuarterForDate`](/gmt/reference/plain/calculate/endOfQuarterForDate/): Return the last day of the quarter for a given ISO date.
- [`endOfQuarterForDateTime`](/gmt/reference/plain/calculate/endOfQuarterForDateTime/): Return the end of the quarter for a given ISO datetime.
- [`endOfTime`](/gmt/reference/plain/calculate/endOfTime/): Return the end of the specified time `unit` for a given ISO 8601 time string.
- [`endOfYearMonth`](/gmt/reference/plain/calculate/endOfYearMonth/): The last day of a year-month, as an ISO date.
- [`getDayOfYear`](/gmt/reference/plain/calculate/getDayOfYear/): Return the ordinal day-of-year (1-based) for `value`.
- [`getDaysInMonth`](/gmt/reference/plain/calculate/getDaysInMonth/): Return the number of days in the month containing `value`.
- [`getDaysInYear`](/gmt/reference/plain/calculate/getDaysInYear/): Return the number of days in the calendar year containing `value`.
- [`getDaysInYearMonth`](/gmt/reference/plain/calculate/getDaysInYearMonth/): Return the number of days in a year-month.
- [`getLargestDateDurationUnit`](/gmt/reference/plain/calculate/getLargestDateDurationUnit/): Return the largest DateDurationUnit from the provided array.
- [`getLargestDateTimeDurationUnit`](/gmt/reference/plain/calculate/getLargestDateTimeDurationUnit/): Return the largest DateTimeDurationUnit from the provided array.
- [`getLargestTimeDurationUnit`](/gmt/reference/plain/calculate/getLargestTimeDurationUnit/): Return the largest TimeDurationUnit from the provided array.
- [`getLocaleDayOfWeek`](/gmt/reference/plain/calculate/getLocaleDayOfWeek/): Return the locale-relative day-of-week index for `value`.
- [`getLocaleEndOfWeek`](/gmt/reference/plain/calculate/getLocaleEndOfWeek/): Return the end of the week containing `value`, using `locale`'s first day of week (e.g. fr-FR: week ends Sunday, ja-JP: week ends Saturday).
- [`getLocaleStartOfWeek`](/gmt/reference/plain/calculate/getLocaleStartOfWeek/): Return the start of the week containing `value`, using `locale`'s first day of week (e.g. fr-FR: Monday, ja-JP: Sunday).
- [`getLocaleWeekYear`](/gmt/reference/plain/calculate/getLocaleWeekYear/): Return the locale-relative week-numbering year `value` belongs to, from `locale`'s first day of week and a minimal-days-in-first-week rule.
- [`getQuarterForDate`](/gmt/reference/plain/calculate/getQuarterForDate/): Return the quarter of the year (1-4) for a given ISO date.
- [`getQuarterForDateTime`](/gmt/reference/plain/calculate/getQuarterForDateTime/): Return the quarter of the year (1-4) for a given ISO datetime.
- [`getWeekNumber`](/gmt/reference/plain/calculate/getWeekNumber/): Calculate the week number based on configurable week start day.
- [`getWeekOfMonth`](/gmt/reference/plain/calculate/getWeekOfMonth/): Return the 1-based row `value` falls on within its month's calendar grid, using `locale`'s first day of week.
- [`getWeeksInLocaleWeekYear`](/gmt/reference/plain/calculate/getWeeksInLocaleWeekYear/): Return the number of weeks (52 or 53) in the locale week-numbering year containing `value`, from `locale`'s first day of week and a minimal-days-in-first-week rule.
- [`getWeeksInMonth`](/gmt/reference/plain/calculate/getWeeksInMonth/): Return the number of calendar-grid rows (4, 5, or 6) `value`'s month spans, using `locale`'s first day of week.
- [`getWeeksInYear`](/gmt/reference/plain/calculate/getWeeksInYear/): Return the number of ISO weeks (52 or 53) in the ISO week-numbering year containing `value`.
- [`getWeekYear`](/gmt/reference/plain/calculate/getWeekYear/): Return the ISO 8601 week-numbering year `value` belongs to.
- [`maxDate`](/gmt/reference/plain/calculate/maxDate/): Return the latest (maximum) of the given PlainDate values.
- [`maxDateTime`](/gmt/reference/plain/calculate/maxDateTime/): Return the latest (maximum) of the given PlainDateTime values.
- [`maxTime`](/gmt/reference/plain/calculate/maxTime/): Return the latest (maximum) of the given PlainTime values.
- [`minDate`](/gmt/reference/plain/calculate/minDate/): Return the earliest (minimum) of the given PlainDate values.
- [`minDateTime`](/gmt/reference/plain/calculate/minDateTime/): Return the earliest (minimum) of the given PlainDateTime values.
- [`minTime`](/gmt/reference/plain/calculate/minTime/): Return the earliest (minimum) of the given PlainTime values.
- [`nextWeekday`](/gmt/reference/plain/calculate/nextWeekday/): Return a PlainDate ISO string for the next occurrence of `dayOfWeek` after `value` (or on it, with `inclusive: true`).
- [`previousWeekday`](/gmt/reference/plain/calculate/previousWeekday/): Return a PlainDate ISO string for the previous occurrence of `dayOfWeek` before `value` (or on it, with `inclusive: true`).
- [`roundDate`](/gmt/reference/plain/calculate/roundDate/): Round an ISO 8601 date string to the specified date unit.
- [`roundDateTime`](/gmt/reference/plain/calculate/roundDateTime/): Round an ISO 8601 datetime string to the specified date-time unit.
- [`roundTime`](/gmt/reference/plain/calculate/roundTime/): Round an ISO 8601 time string to the specified time unit.
- [`setDate`](/gmt/reference/plain/calculate/setDate/): Return a PlainDate ISO string with the given `fields` set on `value`.
- [`setDateTime`](/gmt/reference/plain/calculate/setDateTime/): Return a PlainDateTime ISO string with the given `fields` set on `value`.
- [`setTime`](/gmt/reference/plain/calculate/setTime/): Return a PlainTime ISO string with the given `fields` set on `value`.
- [`sortDates`](/gmt/reference/plain/calculate/sortDates/): Sort an array of PlainDate values in ascending or descending order.
- [`sortDateTimes`](/gmt/reference/plain/calculate/sortDateTimes/): Sort an array of PlainDateTime values in ascending or descending order.
- [`sortTimes`](/gmt/reference/plain/calculate/sortTimes/): Sort an array of PlainTime values in ascending or descending order.
- [`startOfDate`](/gmt/reference/plain/calculate/startOfDate/): Return the start of the specified date `unit` for a given ISO 8601 date string.
- [`startOfDateTime`](/gmt/reference/plain/calculate/startOfDateTime/): Return the start of the specified date-time `unit` for a given ISO 8601 datetime string.
- [`startOfQuarterForDate`](/gmt/reference/plain/calculate/startOfQuarterForDate/): Return the first day of the quarter for a given ISO date.
- [`startOfQuarterForDateTime`](/gmt/reference/plain/calculate/startOfQuarterForDateTime/): Return the start of the quarter for a given ISO datetime.
- [`startOfTime`](/gmt/reference/plain/calculate/startOfTime/): Return the start of the specified time `unit` for a given ISO 8601 time string.
- [`startOfYearMonth`](/gmt/reference/plain/calculate/startOfYearMonth/): The first day of a year-month, as an ISO date.
- [`subtractBusinessDays`](/gmt/reference/plain/calculate/subtractBusinessDays/): Return a PlainDate ISO string with `amount` working days subtracted from `value`.
- [`subtractDate`](/gmt/reference/plain/calculate/subtractDate/): Return a PlainDate ISO string with `units` subtracted from `value`.
- [`subtractDateTime`](/gmt/reference/plain/calculate/subtractDateTime/): Return a PlainDateTime ISO string with `units` subtracted from `value`.
- [`subtractTime`](/gmt/reference/plain/calculate/subtractTime/): Return a PlainTime ISO string with `units` subtracted from `value`.
- [`subtractYearMonth`](/gmt/reference/plain/calculate/subtractYearMonth/): Return a year-month string moved backward by `units`.
- [`weekOfYearForDate`](/gmt/reference/plain/calculate/weekOfYearForDate/): Return the ISO week number for a given ISO 8601 date string.
- [`weekOfYearForDateTime`](/gmt/reference/plain/calculate/weekOfYearForDateTime/): Return the ISO week number for a given ISO 8601 datetime string.

## Types

- [`EndOfTimeUnit`](/gmt/reference/plain/calculate/endOfTime/#endoftimeunit): Units `endOfTime` accepts: a Temporal time unit, or `"day"` for the last moment of the day, each singular or plural.
- [`StartOfTimeUnit`](/gmt/reference/plain/calculate/startOfTime/#startoftimeunit): Units `startOfTime` accepts: a Temporal time unit, or `"day"` for midnight, each singular or plural.
