Skip to content

charton API


charton API / @chart-on/core / index / Zone

Class: Zone ​

Defined in: packages/core/src/util/timezone.ts:53

An IANA timezone. Converts between unix time and wall-clock time ("what the clock on the wall shows"), DST-correct via Intl. Wall time is expressed as seconds read with UTC getters, so new Date(wall * 1000).getUTCHours() is the local hour.

Intl lookups are slow (microseconds each), so the zone finds where its offset changes once per block and answers every other lookup from that.

Constructors ​

Constructor ​

new Zone(name): Zone

Defined in: packages/core/src/util/timezone.ts:63

Throws a RangeError for unknown timezone names.

Parameters ​

name ​

string

Returns ​

Zone

Properties ​

isUtc ​

readonly isUtc: boolean

Defined in: packages/core/src/util/timezone.ts:54


name ​

readonly name: string

Defined in: packages/core/src/util/timezone.ts:63

Methods ​

date() ​

date(time): Date

Defined in: packages/core/src/util/timezone.ts:161

A Date whose UTC fields are the wall-clock fields at time.

Parameters ​

time ​

number

Returns ​

Date


fromWall() ​

fromWall(wall): number

Defined in: packages/core/src/util/timezone.ts:152

Unix time of a wall-clock time. Ambiguous times (clocks going back) resolve to the first occurrence; skipped times (clocks going forward) move forward.

Parameters ​

wall ​

number

Returns ​

number


offset() ​

offset(time): number

Defined in: packages/core/src/util/timezone.ts:70

Seconds to add to unix time to get wall-clock time at time.

Parameters ​

time ​

number

Returns ​

number


wall() ​

wall(time): number

Defined in: packages/core/src/util/timezone.ts:144

Parameters ​

time ​

number

Returns ​

number