@phensley/timezone
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -28,2 +28,30 @@ import { RawData } from './types'; | ||
/** | ||
* Represents metadata associated with a timezone. | ||
* | ||
* @public | ||
*/ | ||
export interface ZoneMeta { | ||
/** | ||
* Time zone identifier. Corrected if the metadata was looked up using an alias. | ||
*/ | ||
zoneid: string; | ||
/** | ||
* Current standard offset from UTC, in milliseconds. | ||
*/ | ||
stdoffset: number; | ||
/** | ||
* Latitude of the zone's "principal location". | ||
*/ | ||
latitude: number; | ||
/** | ||
* Longitude of the zone's "principal location". | ||
*/ | ||
longitude: number; | ||
/** | ||
* ISO 3166 2-character country code for all countries which | ||
* overlap the timezone. | ||
*/ | ||
countries: string[]; | ||
} | ||
/** | ||
* Interface to accessing time zone data. | ||
@@ -60,2 +88,10 @@ * | ||
/** | ||
* Metadata related to a zone, such as the list of country codes that overlap with | ||
* the zone, the latitude and longitude, and the current standard offset, in milliseconds. | ||
* These can be used to display user interfaces for selecting a zone. | ||
* | ||
* If the zone identifier does not match a known zone or alias this returns undefined. | ||
*/ | ||
zoneMeta(id: string): ZoneMeta | undefined; | ||
/** | ||
* Returns an array of time zone ids. | ||
@@ -104,2 +140,8 @@ */ | ||
/** | ||
* Metadata related to a zone, such as the list of country codes that overlap with | ||
* the zone, the latitude and longitude, and the current standard offset, in milliseconds. | ||
* These can be used to display user interfaces for selecting a zone. | ||
*/ | ||
zoneMeta(id: string): ZoneMeta | undefined; | ||
/** | ||
* Returns an array of time zone ids. | ||
@@ -106,0 +148,0 @@ */ |
@@ -77,2 +77,20 @@ import { __assign } from "tslib"; | ||
/** | ||
* Metadata related to a zone, such as the list of country codes that overlap with | ||
* the zone, the latitude and longitude, and the current standard offset, in milliseconds. | ||
* These can be used to display user interfaces for selecting a zone. | ||
*/ | ||
TzImpl.prototype.zoneMeta = function (id) { | ||
var rec = this.record(id); | ||
if (rec) { | ||
return { | ||
zoneid: rec[0], | ||
stdoffset: rec[1].stdoff, | ||
latitude: rec[1].latitude, | ||
longitude: rec[1].longitude, | ||
countries: rec[1].countries, | ||
}; | ||
} | ||
return; | ||
}; | ||
/** | ||
* Returns an array of time zone ids. | ||
@@ -131,3 +149,3 @@ */ | ||
function ZoneRecord(raw, index) { | ||
var _a = raw.split('_'), _info = _a[0], _types = _a[1], _untils = _a[2]; | ||
var _a = raw.split('_'), _std = _a[0], _lat = _a[1], _lon = _a[2], _countries = _a[3], _info = _a[4], _types = _a[5], _untils = _a[6]; | ||
var untils = numarray(_untils); | ||
@@ -143,2 +161,6 @@ var types = _types ? _types.split('').map(function (t) { return TYPES[t]; }) : []; | ||
} | ||
this.stdoff = parseInt(_std, 36) * 1000; | ||
this.latitude = parseInt(_lat, 36) / 1e6; | ||
this.longitude = parseInt(_lon, 36) / 1e6; | ||
this.countries = _countries ? _countries.split(',') : []; | ||
this.localtime = _info.split('|').map(this.decodeInfo); | ||
@@ -145,0 +167,0 @@ this.types = types; |
@@ -28,2 +28,30 @@ import { RawData } from './types'; | ||
/** | ||
* Represents metadata associated with a timezone. | ||
* | ||
* @public | ||
*/ | ||
export interface ZoneMeta { | ||
/** | ||
* Time zone identifier. Corrected if the metadata was looked up using an alias. | ||
*/ | ||
zoneid: string; | ||
/** | ||
* Current standard offset from UTC, in milliseconds. | ||
*/ | ||
stdoffset: number; | ||
/** | ||
* Latitude of the zone's "principal location". | ||
*/ | ||
latitude: number; | ||
/** | ||
* Longitude of the zone's "principal location". | ||
*/ | ||
longitude: number; | ||
/** | ||
* ISO 3166 2-character country code for all countries which | ||
* overlap the timezone. | ||
*/ | ||
countries: string[]; | ||
} | ||
/** | ||
* Interface to accessing time zone data. | ||
@@ -60,2 +88,10 @@ * | ||
/** | ||
* Metadata related to a zone, such as the list of country codes that overlap with | ||
* the zone, the latitude and longitude, and the current standard offset, in milliseconds. | ||
* These can be used to display user interfaces for selecting a zone. | ||
* | ||
* If the zone identifier does not match a known zone or alias this returns undefined. | ||
*/ | ||
zoneMeta(id: string): ZoneMeta | undefined; | ||
/** | ||
* Returns an array of time zone ids. | ||
@@ -104,2 +140,8 @@ */ | ||
/** | ||
* Metadata related to a zone, such as the list of country codes that overlap with | ||
* the zone, the latitude and longitude, and the current standard offset, in milliseconds. | ||
* These can be used to display user interfaces for selecting a zone. | ||
*/ | ||
zoneMeta(id: string): ZoneMeta | undefined; | ||
/** | ||
* Returns an array of time zone ids. | ||
@@ -106,0 +148,0 @@ */ |
@@ -79,2 +79,20 @@ "use strict"; | ||
/** | ||
* Metadata related to a zone, such as the list of country codes that overlap with | ||
* the zone, the latitude and longitude, and the current standard offset, in milliseconds. | ||
* These can be used to display user interfaces for selecting a zone. | ||
*/ | ||
TzImpl.prototype.zoneMeta = function (id) { | ||
var rec = this.record(id); | ||
if (rec) { | ||
return { | ||
zoneid: rec[0], | ||
stdoffset: rec[1].stdoff, | ||
latitude: rec[1].latitude, | ||
longitude: rec[1].longitude, | ||
countries: rec[1].countries, | ||
}; | ||
} | ||
return; | ||
}; | ||
/** | ||
* Returns an array of time zone ids. | ||
@@ -133,3 +151,3 @@ */ | ||
function ZoneRecord(raw, index) { | ||
var _a = raw.split('_'), _info = _a[0], _types = _a[1], _untils = _a[2]; | ||
var _a = raw.split('_'), _std = _a[0], _lat = _a[1], _lon = _a[2], _countries = _a[3], _info = _a[4], _types = _a[5], _untils = _a[6]; | ||
var untils = numarray(_untils); | ||
@@ -145,2 +163,6 @@ var types = _types ? _types.split('').map(function (t) { return TYPES[t]; }) : []; | ||
} | ||
this.stdoff = parseInt(_std, 36) * 1000; | ||
this.latitude = parseInt(_lat, 36) / 1e6; | ||
this.longitude = parseInt(_lon, 36) / 1e6; | ||
this.countries = _countries ? _countries.split(',') : []; | ||
this.localtime = _info.split('|').map(this.decodeInfo); | ||
@@ -147,0 +169,0 @@ this.types = types; |
{ | ||
"name": "@phensley/timezone", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Compact timezone lib based on tz database", | ||
@@ -40,3 +40,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@phensley/cldr-utils": "^1.2.1", | ||
"@phensley/cldr-utils": "^1.2.2", | ||
"tslib": "^1.13.0" | ||
@@ -85,3 +85,3 @@ }, | ||
}, | ||
"gitHead": "b4e3308079a0bcb58a666cd94c248ffd452b2486" | ||
"gitHead": "460f70940516f33a1fcb709c4f62ae83fec113cc" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
364358
2244
Updated@phensley/cldr-utils@^1.2.2