A helper class for formatting and parsing times.

Hierarchy (view full)

Implements

Constructors

Properties

defaultParseFormat: string

Either a single format, or one of several possible formats that the input is expected to be in. If specified, the input must exactly match. The syntax is the same as for utilities/format/time!TimeFormatter.format.

locale: string

The locale to use when formatting & parsing the time. If not specified, the current locale is used (see locale module).

Accessors

Methods

  • Sets the properties for this item.

    This version will also await any asynchronous logic that is needed to set the properties.

    Parameters

    • properties: Partial<TimeFormatterProperties>

      A plain object containing property values to set, keyed by property name.

    Returns Promise<void>

  • Waits for all deserialization logic initiated thus far to finish, whether invoked by passing properties into the constructor, or by invoking assignProperties() or assignPropertiesAsync().

    Returns Promise<void>

  • Formats a time for display.

    Parameters

    • time: Time

      The time to format.

    Returns string

  • Formats a time for display.

    Parameters

    • format: string

      The format for presenting times. One of the utilities/format/formats!TimeFormat constants, or a custom format string. The format string syntax is similar to https://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx, with the following exceptions:

      • ":" is treated as a literal character.
      • "t" is treated the same as "tt".
      • "F", "FF", "FFF" etc. will behave the same as "f", "ff", "fff", etc. Additionally, a maximum of 3 digits (milliseconds) is supported. Longer formatters like "fffff" are truncated to 3 digits, rather than padded with zeros.
      • "K" is not supported at all and will be ignored. If not specified, it will default to TIME_SHORT.
    • time: Time

      The time to format.

    Returns string

  • Formats a time for display.

    Parameters

    • options: FormatOptions

      Options that control how the time is formatted.

    • time: Time

      The time to format.

    Returns string

  • Parses a value into a Time object.

    Parameters

    • input: unknown

      The input to parse.

    Returns Time

    A Time object corresponding to the input. If unable to parse successfully, will return an invalid Time.

  • Parses a value into a Time object.

    Parameters

    Returns Time

    A Time object corresponding to the input. If unable to parse successfully, will return an invalid Time.

  • Parses a value into a Time object.

    Parameters

    • options: ParseOptions

      The options to use for parsing.

    • input: unknown

      The input to parse.

    Returns Time

    A Time object corresponding to the input. If unable to parse successfully, will return an invalid Time.