Skip to content

duration

  • The core functions, which every industry uses.
  • absDuration: Return the absolute value of an ISO 8601 duration string.
  • addDuration: Combine two ISO 8601 duration strings by addition.
  • durationFromUnits: Write an amount given as a unit object, such as { minutes: 15 }, as an ISO 8601 duration string.
  • getDurationSign: Report whether an ISO 8601 duration is negative, zero-length, or positive.
  • getDurationUnit: Read a single component out of an ISO 8601 duration string.
  • negateDuration: Flip the sign of an ISO 8601 duration string.
  • subtractDuration: Combine two ISO 8601 duration strings by subtraction.
  • totalDuration: Express an ISO 8601 duration as a single fractional total in one unit.
  • totalUnits: Express an amount written as a unit object, such as { minutes: 15 }, as a single fractional total in one unit.
  • totalUnitsFromNow: Express a length of time from now as one fractional total in one unit.
  • ttlFromNow: Express one length of time from now in every form a receiver wants: seconds, milliseconds, a Unix epoch, an HTTP date and a UTC string.
  • formatDuration: Render an ISO 8601 duration string as a locale-aware, human-readable string.
  • formatHumanDuration: Write an ISO 8601 duration in the compact form parseHumanDuration reads, such as 2h 30m.
  • normalizeDuration: Roll an ISO 8601 duration string’s small units into larger ones.
  • parseDuration: Parse and re-normalize an ISO 8601 duration string.
  • parseHumanDuration: Read a duration written the way people write it, such as 2h 30m, 1.5h or 3 days, into an ISO 8601 duration string.
  • isValidDuration: Return true if value is a valid ISO 8601 duration string.
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.