Timezone

Timezone utility class for handling IANA timezone conversions and offsets. All methods are static and work with UTC dates.

Props

The following table outlines the props for the Timezone:

NameTypeDefaultDescription
timezoneData
-

Common IANA timezone identifiers for the timezone selector.

Methods

The following table outlines the methods for the Timezone:

NameParametersReturnsDescription
add
  • date

    : Date
  • timezone

    : string
  • Date

    Convert a UTC date to the display wall-clock time in a target timezone. Adds the timezone offset to shift UTC to local time in the target zone.


    Params:
  • date: UTC date to convert
  • timezone: Target IANA timezone name
  • convert
  • date

    : Date
  • fromOffsetOrZone

    : number | string
  • toOffsetOrZone

    : number | string
  • Date

    Convert a wall-clock time from one timezone/offset to another. Takes a date interpreted in the source timezone and converts it to target timezone.


    Params:
  • date: Wall-clock date (assumed to be in source timezone)
  • fromOffsetOrZone: Source timezone: numeric offset (minutes) or IANA name
  • toOffsetOrZone: Target timezone: numeric offset (minutes) or IANA name
  • getLocalTimezoneName
    -
    string

    Get a list of common IANA timezone identifiers for use in editor/UI selectors.

    offset
  • date

    : Date
  • timezone

    : string
  • number

    Get the UTC offset in minutes for a given date and timezone. Accounts for DST active at that specific date.


    Params:
  • date: The date to calculate offset for (assumed UTC)
  • timezone: IANA timezone name (e.g., 'America/New_York')
  • remove
  • date

    : Date
  • timezone

    : string
  • Date

    Remove the timezone offset from a wall-clock date, returning UTC equivalent. Interprets the input date as a local wall-clock in the given timezone and converts it to the equivalent UTC instant.


    Params:
  • date: Wall-clock date in the source timezone (as a Date object)
  • timezone: Source IANA timezone name
  • removeLocalOffset
  • date

    : Date
  • Date

    Remove the local runtime offset from a date. Useful when Date objects are created in local time and need normalization to UTC.


    Params:
  • date: Date in local runtime timezone