Skip to content

getLargestDateTimeDurationUnit

  • The core functions, which every industry uses.
getLargestDateTimeDurationUnit(units: (keyof DurationLikeObject | DateTimeUnit)[]): "" | keyof DurationLikeObject

Return the largest DateTimeDurationUnit from the provided array.

  • Returns the largest unit based on Temporal’s unit order: years > months > weeks > days > hours > minutes > seconds > milliseconds > microseconds > nanoseconds.
  • Each unit may be singular or plural ("day" or "days"), as Temporal accepts; the result is the plural name.
  • Returns "" when units is 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 units returned a default unit ("seconds").
ParameterTypeDescription
units(keyof DurationLikeObject | DateTimeUnit)[]array of DateTimeDurationUnits (singular or plural names) to evaluate

the largest DateTimeDurationUnit found in the array, or "" on invalid input

import { getLargestDateTimeDurationUnit } from "@northguild/gmt/plain/calculate";
getLargestDateTimeDurationUnit(["hours", "minutes", "seconds"]) // "hours"
units
output 

plain/calculate/getLargestDateTimeDurationUnit.ts

Accessibility
© 2026 NorthGuild · Licences

Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.