Options
All
  • Public
  • Public/Protected
  • All
Menu

timezonecomplete

Index

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

Object literals

Type aliases

PeriodDstJson

PeriodDstJson: "regular" | "local"

PeriodDst encoded a a string

Variables

Const ERA_NAMES_ABBREVIATED

ERA_NAMES_ABBREVIATED: [string, string] = ["AD", "BC"]

Const ERA_NAMES_NARROW

ERA_NAMES_NARROW: [string, string] = ["A", "B"]

Const ERA_NAMES_WIDE

ERA_NAMES_WIDE: [string, string] = ["Anno Domini", "Before Christ"]

Const LONG_MONTH_NAMES

LONG_MONTH_NAMES: string[] = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

Const LONG_WEEKDAY_NAMES

LONG_WEEKDAY_NAMES: string[] = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]

Const MONTH_LETTERS

MONTH_LETTERS: string[] = ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"]

Const QUARTER_ABBREVIATIONS

QUARTER_ABBREVIATIONS: string[] = ["1st", "2nd", "3rd", "4th"]

Const QUARTER_LETTER

QUARTER_LETTER: string = "Q"

Const QUARTER_WORD

QUARTER_WORD: string = "quarter"

Const SHORT_MONTH_NAMES

SHORT_MONTH_NAMES: string[] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]

Const SHORT_WEEKDAY_NAMES

SHORT_WEEKDAY_NAMES: string[] = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]

Const STAND_ALONE_LONG_MONTH_NAMES

STAND_ALONE_LONG_MONTH_NAMES: string[] = LONG_MONTH_NAMES.slice()

Const STAND_ALONE_MONTH_LETTERS

STAND_ALONE_MONTH_LETTERS: string[] = MONTH_LETTERS.slice()

Const STAND_ALONE_QUARTER_ABBREVIATIONS

STAND_ALONE_QUARTER_ABBREVIATIONS: string[] = QUARTER_ABBREVIATIONS.slice()

Const STAND_ALONE_QUARTER_LETTER

STAND_ALONE_QUARTER_LETTER: string = QUARTER_LETTER

In some languages, different words are necessary for stand-alone quarter names

Const STAND_ALONE_QUARTER_WORD

STAND_ALONE_QUARTER_WORD: string = QUARTER_WORD

Const STAND_ALONE_SHORT_MONTH_NAMES

STAND_ALONE_SHORT_MONTH_NAMES: string[] = SHORT_MONTH_NAMES.slice()

Const WEEKDAY_LETTERS

WEEKDAY_LETTERS: string[] = ["S", "M", "T", "W", "T", "F", "S"]

Const WEEKDAY_TWO_LETTERS

WEEKDAY_TWO_LETTERS: string[] = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]

Const WHITESPACE

WHITESPACE: string[] = [" ", "\t", "\r", "\v", "\n"]

Functions

_formatDay

  • Format the day of the month (or year)

    throws

    nothing

    Parameters

    • dateTime: TimeStruct

      The current time to format

    • token: Token

      The token passed

    Returns string

    string

_formatDayPeriod

  • Format the Day Period (AM or PM)

    throws

    nothing

    Parameters

    Returns string

    string

_formatEra

  • Format the era (BC or AD)

    throws

    nothing

    Parameters

    Returns string

    string

_formatHour

  • Format the Hour

    throws

    nothing

    Parameters

    • dateTime: TimeStruct

      The current time to format

    • token: Token

      The token passed

    Returns string

    string

_formatMinute

  • Format the minute

    throws

    nothing

    Parameters

    • dateTime: TimeStruct

      The current time to format

    • token: Token

      The token passed

    Returns string

    string

_formatMonth

  • Format the month

    throws

    timezonecomplete.Argument.FormatString for invalid format pattern

    Parameters

    Returns string

    string

_formatQuarter

  • Format the quarter

    throws

    timezonecomplete.Argument.FormatString for invalid format pattern

    Parameters

    Returns string

    string

_formatSecond

  • Format the seconds (or fraction of a second)

    throws

    timezonecomplete.Argument.** if any of the given dateTime elements are invalid

    Parameters

    • dateTime: TimeStruct

      The current time to format

    • token: Token

      The token passed

    Returns string

    string

_formatWeek

  • Format the week number

    throws

    nothing

    Parameters

    • dateTime: TimeStruct

      The current time to format

    • token: Token

      The token passed

    Returns string

    string

_formatWeekday

  • Format the day of the week

    throws

    nothing

    Parameters

    Returns string

    string

_formatYear

  • Format the year

    throws

    nothing

    Parameters

    • dateTime: TimeStruct

      The current time to format

    • token: Token

      The token passed

    Returns string

    string

_formatZone

  • Format the time zone. For this, we need the current time, the time in UTC and the time zone

    throws

    timezonecomplete.InvalidTimeZoneData if values in the time zone database are invalid

    Parameters

    • currentTime: TimeStruct

      The time to format

    • utcTime: TimeStruct

      The time in UTC

    • zone: TimeZone | undefined

      The timezone currentTime is in

    • token: Token

      The token passed

    Returns string

    string

abs

  • Returns the absolute value of a Duration

    throws

    timezonecomplete.Argument.D if d is undefined/null

    Parameters

    Returns Duration

assert

  • assert(condition: any, name: string, format: string, ...args: any[]): assertscondition
  • Throws an Assertion error if the given condition is falsy

    throws

    [name] if condition is falsy

    Parameters

    • condition: any
    • name: string

      error name

    • format: string

      error message with percent-style placeholders

    • Rest ...args: any[]

      arguments for error message format string

    Returns assertscondition

binaryInsertionIndex

  • binaryInsertionIndex<T>(arr: T[], compare: (a: T) => number): number
  • Binary search

    throws

    TypeError if arr is not an array

    throws

    whatever compare() throws

    Type parameters

    • T

    Parameters

    • arr: T[]
    • compare: (a: T) => number

      Function that should return < 0 if given element is less than searched element etc

        • (a: T): number
        • Parameters

          • a: T

          Returns number

    Returns number

    The insertion index of the element to look for

convertError

  • convertError<T>(errorName: string, cb: () => T): T
  • Converts all errors thrown by cb to the given error name

    throws

    [errorName]

    Type parameters

    • T

    Parameters

    • errorName: string
    • cb: () => T
        • (): T
        • Returns T

    Returns T

convertFromUtc

convertToUtc

dayOfYear

  • dayOfYear(year: number, month: number, day: number): number
  • Returns the day of the year of the given date [0..365]. January first is 0.

    throws

    timezonecomplete.Argument.Year for invalid year (non-integer)

    throws

    timezonecomplete.Argument.Month for invalid month

    throws

    timezonecomplete.Argument.Day for invalid day of month

    Parameters

    • year: number

      The year e.g. 1986

    • month: number

      Month 1-12

    • day: number

      Day of month 1-31

    Returns number

days

  • Construct a time duration

    throws

    timezonecomplete.Argument.Amount if n is not a finite number

    Parameters

    • n: number

      Number of days (may be fractional or negative)

    Returns Duration

    A duration of n days

daysInMonth

  • daysInMonth(year: number, month: number): number
  • throws

    timezonecomplete.Argument.Year if year is not integer

    throws

    timezonecomplete.Argument.Month for invalid month number

    Parameters

    • year: number

      The full year

    • month: number

      The month 1-12

    Returns number

    The number of days in the given month

daysInYear

  • daysInYear(year: number): number
  • The days in a given year

    throws

    timezonecomplete.Argument.Year if year is not integer

    Parameters

    • year: number

    Returns number

error

  • error(name: string, format: string, ...args: any[]): Error
  • Returns an error with the given name and message

    throws

    nothing

    Parameters

    • name: string
    • format: string
    • Rest ...args: any[]

    Returns Error

errorIs

  • errorIs(error: Error, name: string | string[]): boolean
  • Returns true iff error.name is equal to or included by name

    throws

    nothing

    Parameters

    • error: Error
    • name: string | string[]

      string or array of strings

    Returns boolean

filterFloat

  • filterFloat(value: string): number
  • Stricter variant of parseFloat().

    throws

    nothing

    Parameters

    • value: string

      Input string

    Returns number

    the float if the string is a valid float, NaN otherwise

firstWeekDayOfMonth

  • firstWeekDayOfMonth(year: number, month: number, weekDay: WeekDay): number
  • Returns the first instance of the given weekday in the given month

    throws

    timezonecomplete.Argument.Year for invalid year (non-integer)

    throws

    timezonecomplete.Argument.Month for invalid month

    throws

    timezonecomplete.Argument.WeekDay for invalid week day

    Parameters

    • year: number

      The year

    • month: number

      the month 1-12

    • weekDay: WeekDay

      the desired week day

    Returns number

    the first occurrence of the week day in the month

format

  • Format the supplied dateTime with the formatting string.

    throws

    timezonecomplete.Argument.FormatString for invalid format pattern

    throws

    timezonecomplete.InvalidTimeZoneData if values in the time zone database are invalid

    Parameters

    • dateTime: TimeStruct

      The current time to format

    • utcTime: TimeStruct

      The time in UTC

    • localZone: TimeZone | undefined | null

      The zone that currentTime is in

    • formatString: string

      The LDML format pattern (see LDML.md)

    • Default value locale: PartialLocale = {}

      Other format options such as month names

    Returns string

    string

getWeekOneDayOfYear

  • getWeekOneDayOfYear(year: number): number
  • Returns the day-of-year of the Monday of week 1 in the given year. Note that the result may lie in the previous year, in which case it will be (much) greater than 4

    throws

    timezonecomplete.Argument.Year for invalid year (non-integer)

    Parameters

    • year: number

    Returns number

hours

  • Construct a time duration

    throws

    timezonecomplete.Argument.Amount if n is not a finite number

    Parameters

    • n: number

      Number of hours (may be fractional or negative)

    Returns Duration

    A duration of n hours

isDateTime

  • isDateTime(value: any): value is DateTime
  • Checks if a given object is of type DateTime. Note that it does not work for sub classes. However, use this to be robust against different versions of the library in one process instead of instanceof

    throws

    nothing

    Parameters

    • value: any

      Value to check

    Returns value is DateTime

isDuration

  • isDuration(value: any): value is Duration
  • Checks if a given object is of type Duration. Note that it does not work for sub classes. However, use this to be robust against different versions of the library in one process instead of instanceof

    throws

    nothing

    Parameters

    • value: any

      Value to check

    Returns value is Duration

isInt

  • isInt(n: number): boolean
  • throws

    nothing

    Parameters

    • n: number

    Returns boolean

    true iff given argument is an integer number

isLeapYear

  • isLeapYear(year: number): boolean
  • throws

    timezonecomplete.Argument.Year if year is not integer

    Parameters

    • year: number

    Returns boolean

    True iff the given year is a leap year.

isPeriod

  • isPeriod(value: any): value is Period
  • Checks if a given object is of type Period. Note that it does not work for sub classes. However, use this to be robust against different versions of the library in one process instead of instanceof

    throws

    nothing

    Parameters

    • value: any

      Value to check

    Returns value is Period

isTimeZone

  • isTimeZone(value: any): value is TimeZone
  • Checks if a given object is of type TimeZone. Note that it does not work for sub classes. However, use this to be robust against different versions of the library in one process instead of instanceof

    throws

    nothing

    Parameters

    • value: any

      Value to check

    Returns value is TimeZone

    a is TimeZone-like

isValidOffsetString

  • isValidOffsetString(s: string): boolean
  • Returns true if the given string is a valid offset string i.e. 1, -1, +1, 01, 1:00, 1:23:25.143

    throws

    nothing

    Parameters

    • s: string

    Returns boolean

isValidPeriodJson

  • Returns true iff the given json value represents a valid period JSON

    throws

    nothing

    Parameters

    Returns boolean

lastWeekDayOfMonth

  • lastWeekDayOfMonth(year: number, month: number, weekDay: WeekDay): number
  • Returns the last instance of the given weekday in the given month

    throws

    timezonecomplete.Argument.Year for invalid year (non-integer)

    throws

    timezonecomplete.Argument.Month for invalid month

    throws

    timezonecomplete.Argument.WeekDay for invalid week day

    Parameters

    • year: number

      The year

    • month: number

      the month 1-12

    • weekDay: WeekDay

      the desired week day 0-6

    Returns number

    the last occurrence of the week day in the month

local

  • The local time zone for a given date as per OS settings. Note that time zones are cached so you don't necessarily get a new object each time.

    throws

    nothing

    Returns TimeZone

max

  • Returns the maximum of two DateTimes

    throws

    timezonecomplete.Argument.D1 if d1 is undefined/null

    throws

    timezonecomplete.Argument.D2 if d1 is undefined/null, or if d1 and d2 are not both datetimes

    Parameters

    Returns DateTime

  • Returns the maximum of two Durations

    throws

    timezonecomplete.Argument.D1 if d1 is undefined/null

    throws

    timezonecomplete.Argument.D2 if d1 is undefined/null, or if d1 and d2 are not both datetimes

    Parameters

    Returns Duration

milliseconds

  • Construct a time duration

    throws

    timezonecomplete.Argument.Amount if n is not a finite number

    Parameters

    • n: number

      Number of milliseconds (may be fractional or negative)

    Returns Duration

    A duration of n milliseconds

min

  • Returns the minimum of two DateTimes

    throws

    timezonecomplete.Argument.D1 if d1 is undefined/null

    throws

    timezonecomplete.Argument.D2 if d1 is undefined/null, or if d1 and d2 are not both datetimes

    Parameters

    Returns DateTime

  • Returns the minimum of two Durations

    throws

    timezonecomplete.Argument.D1 if d1 is undefined/null

    throws

    timezonecomplete.Argument.D2 if d1 is undefined/null, or if d1 and d2 are not both datetimes

    Parameters

    Returns Duration

minutes

  • Construct a time duration

    throws

    timezonecomplete.Argument.Amount if n is not a finite number

    Parameters

    • n: number

      Number of minutes (may be fractional or negative)

    Returns Duration

    A duration of n minutes

monthNameToNumber

  • monthNameToNumber(name: string): number
  • Turns a month name from the TZ database into a number 1-12

    throws

    timezonecomplete.InvalidTimeZoneData for invalid month name

    Parameters

    • name: string

    Returns number

months

  • Construct a time duration

    throws

    timezonecomplete.Argument.Amount if n is not a finite number

    Parameters

    • n: number

      Number of months (may be fractional or negative)

    Returns Duration

    A duration of n months

normalizeTimeComponents

  • Fill you any missing time component parts, defaults are 1970-01-01T00:00:00.000

    throws

    timezonecomplete.Argument.Year for invalid year

    throws

    timezonecomplete.Argument.Month for invalid month

    throws

    timezonecomplete.Argument.Day for invalid day of month

    throws

    timezonecomplete.Argument.Hour for invalid hour

    throws

    timezonecomplete.Argument.Minute for invalid minute

    throws

    timezonecomplete.Argument.Second for invalid second

    throws

    timezonecomplete.Argument.Milli for invalid milliseconds

    Parameters

    Returns TimeComponents

now

  • Current date+time in the given time zone

    throws

    timezonecomplete.NotFound.Zone if the UTC time zone doesn't exist in the time zone database

    Parameters

    • Default value timeZone: TimeZone | undefined | null = TimeZone.utc()

      The desired time zone (optional, defaults to UTC).

    Returns DateTime

nowLocal

nowUtc

  • Current date+time in UTC time

    throws

    timezonecomplete.NotFound.Zone if the UTC time zone doesn't exist in the time zone database

    Returns DateTime

padLeft

  • padLeft(s: string, width: number, char: string): string
  • Pad a string by adding characters to the beginning.

    throws

    timezonecomplete.Argument.Width if width is not an integer number >= 0

    Parameters

    • s: string

      the string to pad

    • width: number

      the desired minimum string width

    • char: string

      the single character to pad with

    Returns string

    the padded string

padRight

  • padRight(s: string, width: number, char: string): string
  • Pad a string by adding characters to the end.

    throws

    timezonecomplete.Argument.Width if width is not an integer number >= 0

    Parameters

    • s: string

      the string to pad

    • width: number

      the desired minimum string width

    • char: string

      the single character to pad with

    Returns string

    the padded string

parse

  • Parse the supplied dateTime assuming the given format.

    throws

    timezonecomplete.ParseError if the given dateTimeString is wrong or not according to the pattern

    throws

    timezonecomplete.Argument.FormatString if the given format string is invalid

    Parameters

    • dateTimeString: string

      The string to parse

    • formatString: string

      The formatting string to be applied

    • Optional overrideZone: TimeZone | null | undefined

      Use this zone in the result

    • Default value allowTrailing: boolean = true

      Allow trailing characters in the source string

    • Default value locale: PartialLocale = {}

      Locale-specific constants such as month names

    Returns AwareTimeStruct

    string

parseable

  • parseable(dateTimeString: string, formatString: string, allowTrailing?: boolean, locale?: PartialLocale): boolean
  • Checks if a given datetime string is according to the given format

    throws

    nothing

    Parameters

    • dateTimeString: string

      The string to test

    • formatString: string

      LDML format string (see LDML.md)

    • Default value allowTrailing: boolean = true

      Allow trailing string after the date+time

    • Default value locale: PartialLocale = {}

      Locale-specific constants such as month names

    Returns boolean

    true iff the string is valid

periodDstToString

  • Convert a PeriodDst to a string: "regular intervals" or "regular local time"

    throws

    timezonecomplete.Argument.P for invalid PeriodDst value

    Parameters

    Returns string

positiveModulo

  • positiveModulo(value: number, modulo: number): number
  • Modulo function that only returns a positive result, in contrast to the % operator

    throws

    timezonecomplete.Argument.Value if value is not finite

    throws

    timezonecomplete.Argument.Modulo if modulo is not a finite number >= 1

    Parameters

    • value: number
    • modulo: number

    Returns number

roundSym

  • roundSym(n: number): number
  • Rounds -1.5 to -2 instead of -1 Rounds +1.5 to +2

    throws

    timezonecomplete.Argument.N if n is not a finite number

    Parameters

    • n: number

    Returns number

ruleTransitionUtc

secondOfDay

  • secondOfDay(hour: number, minute: number, second: number): number
  • N-th second in the day, counting from 0

    throws

    timezonecomplete.Argument.Hour for invalid hour

    throws

    timezonecomplete.Argument.Minute for invalid minute

    throws

    timezonecomplete.Argument.Second for invalid second

    Parameters

    • hour: number
    • minute: number
    • second: number

    Returns number

seconds

  • Construct a time duration

    throws

    timezonecomplete.Argument.Amount if n is not a finite number

    Parameters

    • n: number

      Number of seconds (may be fractional or negative)

    Returns Duration

    A duration of n seconds

stringToTimeUnit

  • Convert a string to a numeric TimeUnit. Case-insensitive; time units can be singular or plural.

    throws

    timezonecomplete.Argument.S for invalid string

    Parameters

    • s: string

    Returns TimeUnit

stripDayPeriod

stripEra

  • stripEra(token: Token, remaining: string, locale: Locale): [number, string]
  • Returns factor -1 or 1 depending on BC or AD

    throws

    timezonecomplete.ParseError

    Parameters

    Returns [number, string]

stripHour

stripMonth

stripNumber

stripQuarter

stripRaw

  • stripRaw(s: string, expected: string): string
  • throws

    timezonecomplete.ParseError

    Parameters

    • s: string
    • expected: string

    Returns string

stripSecond

  • throws

    timezonecomplete.ParseError

    throws

    timezonecomplete.Argument.FormatString

    Parameters

    • token: Token
    • remaining: string

    Returns ParseNumberResult

stripStrings

  • stripStrings(token: Token, remaining: string, allowed: string[]): { chosen: string; remaining: string }
  • throws

    timezonecomplete.ParseError

    Parameters

    • token: Token
    • remaining: string
    • allowed: string[]

    Returns { chosen: string; remaining: string }

    • chosen: string
    • remaining: string

stripWeekDay

  • stripWeekDay(token: Token, remaining: string, locale: Locale): string
  • throws

    timezonecomplete.ParseError

    throws

    timezonecomplete.Argument.FormatString

    Parameters

    Returns string

    remaining string

stripZone

  • throws

    timezonecomplete.NotImplemented if a pattern is used that isn't implemented yet (z, Z, v, V, x, X)

    throws

    timezonecomplete.ParseError if the given string is not parseable

    Parameters

    Returns ParseZoneResult

throwError

  • throwError(name: string, format: string, ...args: any[]): never
  • Throws an error with the given name and message

    throws

    the given error

    Parameters

    • name: string

      error name, without timezonecomplete prefix

    • format: string

      message with percent-style placeholders

    • Rest ...args: any[]

      arguments for the placeholders

    Returns never

timeToUnixNoLeapSecs

  • timeToUnixNoLeapSecs(year: number, month: number, day: number, hour: number, minute: number, second: number, milli: number): number
  • timeToUnixNoLeapSecs(components: TimeComponentOpts): number
  • Convert a year, month, day etc into a unix milli timestamp. This does NOT take leap seconds into account.

    throws

    timezonecomplete.Argument.Year for invalid year

    throws

    timezonecomplete.Argument.Month for invalid month

    throws

    timezonecomplete.Argument.Day for invalid day of month

    throws

    timezonecomplete.Argument.Hour for invalid hour

    throws

    timezonecomplete.Argument.Minute for invalid minute

    throws

    timezonecomplete.Argument.Second for invalid second

    throws

    timezonecomplete.Argument.Milli for invalid milliseconds

    Parameters

    • year: number

      Year e.g. 1970

    • month: number

      Month 1-12

    • day: number

      Day 1-31

    • hour: number

      Hour 0-23

    • minute: number

      Minute 0-59

    • second: number

      Second 0-59 (no leap seconds)

    • milli: number

      Millisecond 0-999

    Returns number

  • Parameters

    Returns number

timeUnitToMilliseconds

  • timeUnitToMilliseconds(unit: TimeUnit): number
  • Approximate number of milliseconds for a time unit. A day is assumed to have 24 hours, a month is assumed to equal 30 days and a year is set to 360 days (because 12 months of 30 days).

    throws

    timezonecomplete.Argument.Unit for invalid unit

    Parameters

    • unit: TimeUnit

      Time unit e.g. TimeUnit.Month

    Returns number

    The number of milliseconds.

timeUnitToString

  • timeUnitToString(unit: TimeUnit, amount?: number): string
  • Time unit to lowercase string. If amount is specified, then the string is put in plural form if necessary.

    throws

    timezonecomplete.Argument.Unit for invalid time unit

    Parameters

    • unit: TimeUnit

      The unit

    • Default value amount: number = 1

      If this is unequal to -1 and 1, then the result is pluralized

    Returns string

timestampOnWeekTimeGreaterThanOrEqualTo

  • Returns the first timestamp >= opts.reference that matches the given weekday and time. Uses the time zone and DST settings of the given reference time.

    throws

    timezonecomplete.Argument.Hour if opts.hour out of range

    throws

    timezonecomplete.Argument.Minute if opts.minute out of range

    throws

    timezonecomplete.Argument.Second if opts.second out of range

    throws

    timezonecomplete.Argument.Millisecond if opts.millisecond out of range

    throws

    timezonecomplete.Argument.Weekday if opts.weekday out of range

    Parameters

    Returns DateTime

timestampOnWeekTimeLessThan

  • Returns the first timestamp < opts.reference that matches the given weekday and time. Uses the time zone and DST settings of the given reference time.

    throws

    timezonecomplete.Argument.Hour if opts.hour out of range

    throws

    timezonecomplete.Argument.Minute if opts.minute out of range

    throws

    timezonecomplete.Argument.Second if opts.second out of range

    throws

    timezonecomplete.Argument.Millisecond if opts.millisecond out of range

    throws

    timezonecomplete.Argument.Weekday if opts.weekday out of range

    Parameters

    Returns DateTime

tokenize

  • tokenize(formatString: string): Token[]
  • Tokenize an LDML date/time format string

    throws

    nothing

    Parameters

    • formatString: string

      the string to tokenize

    Returns Token[]

unixToTimeNoLeapSecs

  • Convert a unix milli timestamp into a TimeT structure. This does NOT take leap seconds into account.

    throws

    timezonecomplete.Argument.UnixMillis for non-integer unixMillis parameter

    Parameters

    • unixMillis: number

    Returns TimeComponents

utc

  • Coordinated Universal Time zone. Note that time zones are cached so you don't necessarily get a new object each time.

    throws

    timezonecomplete.NotFound.Zone if the UTC zone is not present in the time zone database

    Returns TimeZone

validateData

  • Sanity check on data. Returns min/max values.

    throws

    timezonecomplete.InvalidTimeZoneData for invalid data

    Parameters

    • data: any

    Returns MinMaxInfo

weekDayNoLeapSecs

  • weekDayNoLeapSecs(unixMillis: number): WeekDay
  • Return the day-of-week. This does NOT take leap seconds into account.

    throws

    timezonecomplete.Argument.UnixMillis for invalid unixMillis argument

    Parameters

    • unixMillis: number

    Returns WeekDay

weekDayOnOrAfter

  • weekDayOnOrAfter(year: number, month: number, day: number, weekDay: WeekDay): number
  • Returns the day-of-month that is on the given weekday and which is >= the given day; throws if not found

    throws

    timezonecomplete.Argument.Year for invalid year (non-integer)

    throws

    timezonecomplete.Argument.Month for invalid month

    throws

    timezonecomplete.Argument.Day for invalid day of month

    throws

    timezonecomplete.Argument.WeekDay for invalid week day

    throws

    timezonecomplete.NotFound if the month has no such day

    Parameters

    • year: number
    • month: number
    • day: number
    • weekDay: WeekDay

    Returns number

weekDayOnOrBefore

  • weekDayOnOrBefore(year: number, month: number, day: number, weekDay: WeekDay): number
  • Returns the day-of-month that is on the given weekday and which is <= the given day.

    throws

    timezonecomplete.Argument.Year for invalid year (non-integer)

    throws

    timezonecomplete.Argument.Month for invalid month

    throws

    timezonecomplete.Argument.Day for invalid day of month

    throws

    timezonecomplete.Argument.WeekDay for invalid week day

    throws

    timezonecomplete.NotFound if the month has no such day

    Parameters

    • year: number
    • month: number
    • day: number
    • weekDay: WeekDay

    Returns number

weekNumber

  • weekNumber(year: number, month: number, day: number): number
  • The ISO 8601 week number for the given date. Week 1 is the week that has January 4th in it, and it starts on Monday. See https://en.wikipedia.org/wiki/ISO_week_date

    throws

    timezonecomplete.Argument.Year for invalid year (non-integer)

    throws

    timezonecomplete.Argument.Month for invalid month

    throws

    timezonecomplete.Argument.Day for invalid day of month

    Parameters

    • year: number

      Year e.g. 1988

    • month: number

      Month 1-12

    • day: number

      Day of month 1-31

    Returns number

    Week number 1-53

weekOfMonth

  • weekOfMonth(year: number, month: number, day: number): number
  • The week of this month. There is no official standard for this, but we assume the same rules for the weekNumber: week 1 is the week that has the 4th day of the month in it

    throws

    timezonecomplete.Argument.Year for invalid year (non-integer)

    throws

    timezonecomplete.Argument.Month for invalid month

    throws

    timezonecomplete.Argument.Day for invalid day of month

    Parameters

    • year: number

      The year

    • month: number

      The month [1-12]

    • day: number

      The day [1-31]

    Returns number

    Week number [1-5]

years

  • Construct a time duration

    throws

    timezonecomplete.Argument.Amount if n is not a finite number

    Parameters

    • n: number

      Number of years (may be fractional or negative)

    Returns Duration

    A duration of n years

zone

  • zone(offset: number): TimeZone
  • zone(name: string, dst?: undefined | false | true): TimeZone
  • zone() implementation

    throws

    timezonecomplete.Argument.Offset if the given offset is not within -24h...+24h (in minutes)

    Parameters

    • offset: number

      offset w.r.t. UTC in minutes, e.g. 90 for +01:30. Note that time zones are cached so you don't necessarily get a new object each time.

    Returns TimeZone

    a time zone with the given fixed offset

  • Time zone for an offset string or an IANA time zone string. Note that time zones are cached so you don't necessarily get a new object each time.

    throws

    timezonecomplete.Argument.S if s cannot be parsed

    throws

    timezonecomplete.NotFound.Zone if the zone name doesn't exist in the time zone database

    Parameters

    • name: string
    • Optional dst: undefined | false | true

      Optional, default true: adhere to Daylight Saving Time if applicable. Note for "localtime", timezonecomplete will adhere to the computer settings, the DST flag does not have any effect.

    Returns TimeZone

zoneAbbreviation

  • zoneAbbreviation(format: string, dst: boolean, letter: string | undefined): string
  • Calculate the formatted abbreviation for a zone

    Parameters

    • format: string

      the abbreviation format string. Either 'zzz,' for NULL; 'A/B' for std/dst, or 'A%sB' for a format string where %s is replaced by a letter

    • dst: boolean

      whether DST is observed

    • letter: string | undefined

      current rule letter, empty if no rule

    Returns string

    fully formatted abbreviation

Object literals

Const DAY_PERIODS_ABBREVIATED

DAY_PERIODS_ABBREVIATED: object

am

am: string = "AM"

midnight

midnight: string = "mid."

noon

noon: string = "noon"

pm

pm: string = "PM"

Const DAY_PERIODS_NARROW

DAY_PERIODS_NARROW: object

am

am: string = "A"

midnight

midnight: string = "md"

noon

noon: string = "noon"

pm

pm: string = "P"

Const DAY_PERIODS_WIDE

DAY_PERIODS_WIDE: object

am

am: string = "AM"

midnight

midnight: string = "midnight"

noon

noon: string = "noon"

pm

pm: string = "PM"

Const DEFAULT_LOCALE

DEFAULT_LOCALE: object

dayPeriodAbbreviated

dayPeriodAbbreviated: { am: string; midnight: string; noon: string; pm: string } = DAY_PERIODS_ABBREVIATED

Type declaration

  • am: string
  • midnight: string
  • noon: string
  • pm: string

dayPeriodNarrow

dayPeriodNarrow: { am: string; midnight: string; noon: string; pm: string } = DAY_PERIODS_NARROW

Type declaration

  • am: string
  • midnight: string
  • noon: string
  • pm: string

dayPeriodWide

dayPeriodWide: { am: string; midnight: string; noon: string; pm: string } = DAY_PERIODS_WIDE

Type declaration

  • am: string
  • midnight: string
  • noon: string
  • pm: string

eraAbbreviated

eraAbbreviated: [string, string] = ERA_NAMES_ABBREVIATED

eraNarrow

eraNarrow: [string, string] = ERA_NAMES_NARROW

eraWide

eraWide: [string, string] = ERA_NAMES_WIDE

longMonthNames

longMonthNames: string[] = LONG_MONTH_NAMES

longWeekdayNames

longWeekdayNames: string[] = LONG_WEEKDAY_NAMES

monthLetters

monthLetters: string[] = MONTH_LETTERS

quarterAbbreviations

quarterAbbreviations: string[] = QUARTER_ABBREVIATIONS

quarterLetter

quarterLetter: string = QUARTER_LETTER

quarterWord

quarterWord: string = QUARTER_WORD

shortMonthNames

shortMonthNames: string[] = SHORT_MONTH_NAMES

shortWeekdayNames

shortWeekdayNames: string[] = SHORT_WEEKDAY_NAMES

standAloneLongMonthNames

standAloneLongMonthNames: string[] = STAND_ALONE_LONG_MONTH_NAMES

standAloneMonthLetters

standAloneMonthLetters: string[] = STAND_ALONE_MONTH_LETTERS

standAloneQuarterAbbreviations

standAloneQuarterAbbreviations: string[] = STAND_ALONE_QUARTER_ABBREVIATIONS

standAloneQuarterLetter

standAloneQuarterLetter: string = STAND_ALONE_QUARTER_LETTER

standAloneQuarterWord

standAloneQuarterWord: string = STAND_ALONE_QUARTER_WORD

standAloneShortMonthNames

standAloneShortMonthNames: string[] = STAND_ALONE_SHORT_MONTH_NAMES

weekdayLetters

weekdayLetters: string[] = WEEKDAY_LETTERS

weekdayTwoLetters

weekdayTwoLetters: string[] = WEEKDAY_TWO_LETTERS

Const SYMBOL_MAPPING

SYMBOL_MAPPING: object

A

A: object

type

type: SECOND = TokenType.SECOND

B

B: object

maxLength

maxLength: number = 5

type

type: DAYPERIOD = TokenType.DAYPERIOD

D

D: object

maxLength

maxLength: number = 3

type

type: DAY = TokenType.DAY

E

E: object

maxLength

maxLength: number = 6

type

type: WEEKDAY = TokenType.WEEKDAY

F

F: object

maxLength

maxLength: number = 1

type

type: DAY = TokenType.DAY

G

G: object

maxLength

maxLength: number = 5

type

type: ERA = TokenType.ERA

H

H: object

maxLength

maxLength: number = 2

type

type: HOUR = TokenType.HOUR

J

J: object

maxLength

maxLength: number = 2

type

type: HOUR = TokenType.HOUR

K

K: object

maxLength

maxLength: number = 2

type

type: HOUR = TokenType.HOUR

L

L: object

maxLength

maxLength: number = 5

type

type: MONTH = TokenType.MONTH

M

M: object

maxLength

maxLength: number = 5

type

type: MONTH = TokenType.MONTH

O

O: object

lengths

lengths: number[] = [1, 4]

type

type: ZONE = TokenType.ZONE

Q

Q: object

maxLength

maxLength: number = 5

type

type: QUARTER = TokenType.QUARTER

S

S: object

type

type: SECOND = TokenType.SECOND

U

U: object

maxLength

maxLength: number = 5

type

type: YEAR = TokenType.YEAR

V

V: object

maxLength

maxLength: number = 4

type

type: ZONE = TokenType.ZONE

W

W: object

maxLength

maxLength: number = 1

type

type: WEEK = TokenType.WEEK

X

X: object

maxLength

maxLength: number = 5

type

type: ZONE = TokenType.ZONE

Y

Y: object

type

type: YEAR = TokenType.YEAR

Z

Z: object

maxLength

maxLength: number = 5

type

type: ZONE = TokenType.ZONE

a

a: object

maxLength

maxLength: number = 5

type

type: DAYPERIOD = TokenType.DAYPERIOD

b

b: object

maxLength

maxLength: number = 5

type

type: DAYPERIOD = TokenType.DAYPERIOD

c

c: object

maxLength

maxLength: number = 6

type

type: WEEKDAY = TokenType.WEEKDAY

d

d: object

maxLength

maxLength: number = 2

type

type: DAY = TokenType.DAY

e

e: object

maxLength

maxLength: number = 6

type

type: WEEKDAY = TokenType.WEEKDAY

g

g: object

type

type: DAY = TokenType.DAY

h

h: object

maxLength

maxLength: number = 2

type

type: HOUR = TokenType.HOUR

j

j: object

maxLength

maxLength: number = 6

type

type: HOUR = TokenType.HOUR

k

k: object

maxLength

maxLength: number = 2

type

type: HOUR = TokenType.HOUR

l

l: object

maxLength

maxLength: number = 1

type

type: MONTH = TokenType.MONTH

m

m: object

maxLength

maxLength: number = 2

type

type: MINUTE = TokenType.MINUTE

q

q: object

maxLength

maxLength: number = 5

type

type: QUARTER = TokenType.QUARTER

r

r: object

type

type: YEAR = TokenType.YEAR

s

s: object

maxLength

maxLength: number = 2

type

type: SECOND = TokenType.SECOND

u

u: object

type

type: YEAR = TokenType.YEAR

v

v: object

lengths

lengths: number[] = [1, 4]

type

type: ZONE = TokenType.ZONE

w

w: object

maxLength

maxLength: number = 2

type

type: WEEK = TokenType.WEEK

x

x: object

maxLength

maxLength: number = 5

type

type: ZONE = TokenType.ZONE

y

y: object

type

type: YEAR = TokenType.YEAR

z

z: object

maxLength

maxLength: number = 4

type

type: ZONE = TokenType.ZONE

Generated using TypeDoc