getLargestDateDurationUnit
Signature
Section titled “Signature”getLargestDateDurationUnit(units: ("years" | "months" | "weeks" | "days" | DateUnit)[]): "years" | "months" | "weeks" | "days" | ""Return the largest DateDurationUnit from the provided array.
- Returns the largest unit based on Temporal’s unit order: years > months > weeks > days.
- Each unit may be singular or plural (
"day"or"days"), as Temporal accepts; the result is the plural name. - Returns "" when
unitsis not an array, is empty, or holds anything that is not a unit of this family. - Compatibility: before 1.16.0 an empty or invalid
unitsreturned a default unit ("days").
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
units | ("years" | "months" | "weeks" | "days" | DateUnit)[] | array of DateDurationUnits (singular or plural names) to evaluate |
Returns
Section titled “Returns”the largest DateDurationUnit found in the array, or "" on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { getLargestDateDurationUnit } from "@northguild/gmt/plain/calculate";
getLargestDateDurationUnit(["months", "days"]) // "months"