@phensley/timezone
Advanced tools
Comparing version 0.11.1-alpha.0 to 0.11.2-alpha.0
@@ -10,3 +10,5 @@ import { RawData } from './types'; | ||
fromUTC(zoneid: string, utc: number): ZoneInfo | undefined; | ||
fromWall(zoneid: string, utc: number): ZoneInfo | undefined; | ||
resolveId(id: string): string | undefined; | ||
utcZone(): ZoneInfo; | ||
zoneIds(): string[]; | ||
} | ||
@@ -36,3 +38,2 @@ export declare class TzImpl { | ||
*/ | ||
fromWall(zoneid: string, wall: number): ZoneInfo | undefined; | ||
/** | ||
@@ -59,2 +60,2 @@ * UTC zone info. | ||
} | ||
export declare const TZ: TzImpl; | ||
export declare const TZ: Tz; |
@@ -63,5 +63,5 @@ var __assign = (this && this.__assign) || function () { | ||
*/ | ||
TzImpl.prototype.fromWall = function (zoneid, wall) { | ||
return this.lookup(zoneid, wall, false); | ||
}; | ||
// fromWall(zoneid: string, wall: number): ZoneInfo | undefined { | ||
// return this.lookup(zoneid, wall, false); | ||
// } | ||
/** | ||
@@ -88,7 +88,9 @@ * UTC zone info. | ||
*/ | ||
TzImpl.prototype.lookup = function (id, t, isutc) { | ||
TzImpl.prototype.lookup = function (id, t, _isutc) { | ||
var rec = this.record(id); | ||
if (rec) { | ||
var zoneid = rec[0], r = rec[1]; | ||
var res = isutc ? r.fromUTC(t) : r.fromWall(t); | ||
var res = r.fromUTC(t); | ||
// TODO: rework wall -> utc since it can require some guessing | ||
// const res = isutc ? r.fromUTC(t) : r.fromWall(t); | ||
return __assign({}, res, { zoneid: zoneid }); | ||
@@ -155,28 +157,2 @@ } | ||
/** | ||
* Resolve the zone info using a local "wall clock" timestamp. | ||
*/ | ||
ZoneRecord.prototype.fromWall = function (wall) { | ||
var i = binarySearch(this.untils, false, wall); | ||
var type; | ||
if (i === this.len) { | ||
// went off the top end, so return the last info | ||
type = this.types[this.len - 1]; | ||
return this.localtime[type]; | ||
} | ||
// check if the adjusted time is <= wall time | ||
type = this.types[i]; | ||
var loc = this.localtime[type]; | ||
if (this.untils[i] + loc.offset <= wall) { | ||
return loc; | ||
} | ||
// select the next until down and retry | ||
i--; | ||
// went off the bottom end, return the first info | ||
if (i === -1) { | ||
return this.localtime[0]; | ||
} | ||
type = this.types[i]; | ||
return this.localtime[type]; | ||
}; | ||
/** | ||
* Decode a single zone info record. | ||
@@ -183,0 +159,0 @@ */ |
@@ -10,3 +10,5 @@ import { RawData } from './types'; | ||
fromUTC(zoneid: string, utc: number): ZoneInfo | undefined; | ||
fromWall(zoneid: string, utc: number): ZoneInfo | undefined; | ||
resolveId(id: string): string | undefined; | ||
utcZone(): ZoneInfo; | ||
zoneIds(): string[]; | ||
} | ||
@@ -36,3 +38,2 @@ export declare class TzImpl { | ||
*/ | ||
fromWall(zoneid: string, wall: number): ZoneInfo | undefined; | ||
/** | ||
@@ -59,2 +60,2 @@ * UTC zone info. | ||
} | ||
export declare const TZ: TzImpl; | ||
export declare const TZ: Tz; |
@@ -65,5 +65,5 @@ "use strict"; | ||
*/ | ||
TzImpl.prototype.fromWall = function (zoneid, wall) { | ||
return this.lookup(zoneid, wall, false); | ||
}; | ||
// fromWall(zoneid: string, wall: number): ZoneInfo | undefined { | ||
// return this.lookup(zoneid, wall, false); | ||
// } | ||
/** | ||
@@ -90,7 +90,9 @@ * UTC zone info. | ||
*/ | ||
TzImpl.prototype.lookup = function (id, t, isutc) { | ||
TzImpl.prototype.lookup = function (id, t, _isutc) { | ||
var rec = this.record(id); | ||
if (rec) { | ||
var zoneid = rec[0], r = rec[1]; | ||
var res = isutc ? r.fromUTC(t) : r.fromWall(t); | ||
var res = r.fromUTC(t); | ||
// TODO: rework wall -> utc since it can require some guessing | ||
// const res = isutc ? r.fromUTC(t) : r.fromWall(t); | ||
return __assign({}, res, { zoneid: zoneid }); | ||
@@ -157,28 +159,2 @@ } | ||
/** | ||
* Resolve the zone info using a local "wall clock" timestamp. | ||
*/ | ||
ZoneRecord.prototype.fromWall = function (wall) { | ||
var i = cldr_utils_1.binarySearch(this.untils, false, wall); | ||
var type; | ||
if (i === this.len) { | ||
// went off the top end, so return the last info | ||
type = this.types[this.len - 1]; | ||
return this.localtime[type]; | ||
} | ||
// check if the adjusted time is <= wall time | ||
type = this.types[i]; | ||
var loc = this.localtime[type]; | ||
if (this.untils[i] + loc.offset <= wall) { | ||
return loc; | ||
} | ||
// select the next until down and retry | ||
i--; | ||
// went off the bottom end, return the first info | ||
if (i === -1) { | ||
return this.localtime[0]; | ||
} | ||
type = this.types[i]; | ||
return this.localtime[type]; | ||
}; | ||
/** | ||
* Decode a single zone info record. | ||
@@ -185,0 +161,0 @@ */ |
{ | ||
"name": "@phensley/timezone", | ||
"version": "0.11.1-alpha.0", | ||
"version": "0.11.2-alpha.0", | ||
"description": "Compact timezone lib based on tz database", | ||
@@ -40,3 +40,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@phensley/cldr-utils": "^0.11.1-alpha.0" | ||
"@phensley/cldr-utils": "^0.11.2-alpha.0" | ||
}, | ||
@@ -73,3 +73,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "13828e2aa75ca7640d5e4bdef6b42d6723addd6f" | ||
"gitHead": "ea14f5b8b8b3f22aedc505ac3036d96b6c974e22" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
294522
1880