Options
All
  • Public
  • Public/Protected
  • All
Menu

An implementation for time zones using IANA data.

This example gets the data from the internet.

import { IANATimezone, minDataToTimezoneOffset } from '@jetblack/date-tz'

const timezoneName = 'Europe/Brussels'
fetch(`https://cdn.jsdelivr.net/npm/@jetblack/tzdata/dist/latest/${timezoneName}.min.json`)
.then(response => response.json())
.then(data => {
const zoneData = data.map(minDataToTimezoneOffset)
const tz = new IANATimezone(timeZoneName, zoneData)
const newYearsDay = tz.makeDate(2000, 0, 1)
// returns "2000-01-01T01:00:00Z"
})
.catch(error => console.error(error))
}

Hierarchy

  • OffsetTimezone
    • IANATimezone

Index

Constructors

Accessors

  • get name(): string
  • Get the name of the timezone.

    Returns string

Methods

  • Makes a new date by taking the date parts using this timezone and making the date with the supplied time zone.

    Parameters

    • date: Date

      A date

    • tz: Timezone

      A timezone

    Returns Date

    A new date using the date parts from this timezone, constructed with the supplied timezone.

  • day(date: Date): number
  • hours(date: Date): number
  • Parameters

    • date: Date

    Returns number

  • isDaylightSavings(date: Date): boolean
  • Parameters

    • date: Date

    Returns boolean

  • makeDate(year: number, month: number, day?: number, hours?: number, minutes?: number, seconds?: number, milliseconds?: number): Date
  • Parameters

    • year: number
    • month: number
    • Optional day: number
    • Optional hours: number
    • Optional minutes: number
    • Optional seconds: number
    • Optional milliseconds: number

    Returns Date

  • milliseconds(date: Date): number
  • Parameters

    • date: Date

    Returns number

  • minutes(date: Date): number
  • Parameters

    • date: Date

    Returns number

  • month(date: Date): number
  • Parameters

    • date: Date

    Returns number

  • offset(date: Date): number
  • Parameters

    • date: Date

    Returns number

  • seconds(date: Date): number
  • Parameters

    • date: Date

    Returns number

  • toISOString(date: Date): string
  • The ISO 8601 date string representation for a given date.

    Parameters

    • date: Date

      The date.

    Returns string

    The ISO date string.

  • weekday(date: Date): number
  • Parameters

    • date: Date

    Returns number

  • year(date: Date): number

Generated using TypeDoc