• Format time components relative to the current time.

    Parameters

    • calendar: CalendarData<TimeComponents>

      The calendar to use for formatting

    • components: TimeComponents

      The time components to format

    • options: { fromComponents?: TimeComponents; maxTerms?: number; short?: boolean } = {}

      Formatting options

      • OptionalfromComponents?: TimeComponents

        The reference time to measure from (default: the current world time)

      • OptionalmaxTerms?: number

        The maximum number of time components to include (default: 0, all)

      • Optionalshort?: boolean

        Whether to use short format (default: false)

    Returns string

    The formatted timestamp

    The output will describe the time either in the future or in the past. for future as "{years}, {days}, {hours}, {minutes}, {seconds} in the future" for past as "{years}, {days}, {hours}, {minutes}, {seconds} ago". Components with a zero value are omitted from the output. If the time is the current time, "now" is returned.