@js-joda/timezone 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js-joda-timezone-10-year-range.esm.js +18 -14
- package/dist/js-joda-timezone-10-year-range.esm.js.map +1 -1
- package/dist/js-joda-timezone-10-year-range.js +18 -14
- package/dist/js-joda-timezone-10-year-range.js.map +1 -1
- package/dist/js-joda-timezone-10-year-range.min.js +2 -2
- package/dist/js-joda-timezone-300-year-range.esm.js +34 -30
- package/dist/js-joda-timezone-300-year-range.esm.js.map +1 -1
- package/dist/js-joda-timezone-300-year-range.js +34 -30
- package/dist/js-joda-timezone-300-year-range.js.map +1 -1
- package/dist/js-joda-timezone-300-year-range.min.js +2 -2
- package/dist/js-joda-timezone-4-year-range.esm.js +18 -14
- package/dist/js-joda-timezone-4-year-range.esm.js.map +1 -1
- package/dist/js-joda-timezone-4-year-range.js +18 -14
- package/dist/js-joda-timezone-4-year-range.js.map +1 -1
- package/dist/js-joda-timezone-4-year-range.min.js +2 -2
- package/dist/js-joda-timezone-60-year-range.esm.js +18 -14
- package/dist/js-joda-timezone-60-year-range.esm.js.map +1 -1
- package/dist/js-joda-timezone-60-year-range.js +18 -14
- package/dist/js-joda-timezone-60-year-range.js.map +1 -1
- package/dist/js-joda-timezone-60-year-range.min.js +2 -2
- package/dist/js-joda-timezone-empty.esm.js +16 -12
- package/dist/js-joda-timezone-empty.esm.js.map +1 -1
- package/dist/js-joda-timezone-empty.js +16 -12
- package/dist/js-joda-timezone-empty.js.map +1 -1
- package/dist/js-joda-timezone-empty.min.js +2 -2
- package/dist/js-joda-timezone-lifetime-range.esm.js +34 -30
- package/dist/js-joda-timezone-lifetime-range.esm.js.map +1 -1
- package/dist/js-joda-timezone-lifetime-range.js +34 -30
- package/dist/js-joda-timezone-lifetime-range.js.map +1 -1
- package/dist/js-joda-timezone-lifetime-range.min.js +2 -2
- package/dist/js-joda-timezone.esm.js +34 -30
- package/dist/js-joda-timezone.esm.js.map +1 -1
- package/dist/js-joda-timezone.js +34 -30
- package/dist/js-joda-timezone.js.map +1 -1
- package/dist/js-joda-timezone.min.js +2 -2
- package/package.json +3 -3
- package/src/TzdbZoneRules.js +21 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@js-joda/timezone",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "iana tzdb timezone bindings for js-joda",
|
|
5
5
|
"typings": "typings/js-joda-timezone.d.ts",
|
|
6
6
|
"main": "dist/js-joda-timezone.js",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"@js-joda/core": ">=5.7.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@js-joda/core": "^6.3.
|
|
48
|
+
"@js-joda/core": "^6.3.1"
|
|
49
49
|
},
|
|
50
50
|
"license": "BSD-3-Clause",
|
|
51
51
|
"bugs": {
|
|
52
52
|
"url": "https://github.com/js-joda/js-joda/issues"
|
|
53
53
|
},
|
|
54
54
|
"homepage": "https://js-joda.github.io/js-joda",
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "24c247ab29a9b4f2efa45285743c0234df7d6156"
|
|
56
56
|
}
|
package/src/TzdbZoneRules.js
CHANGED
|
@@ -37,7 +37,7 @@ export class TzdbZoneRules extends ZoneRules{
|
|
|
37
37
|
* @return {ZoneOffset} the offset, not null
|
|
38
38
|
*/
|
|
39
39
|
offsetOfInstant(instant){
|
|
40
|
-
const epochMilli = instant
|
|
40
|
+
const epochMilli = epochMilliOf(instant);
|
|
41
41
|
return this.offsetOfEpochMilli(epochMilli);
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -229,7 +229,7 @@ export class TzdbZoneRules extends ZoneRules{
|
|
|
229
229
|
* @throws {Error} if the tz data of the zone has no standard offsets
|
|
230
230
|
*/
|
|
231
231
|
standardOffset(instant){
|
|
232
|
-
return ZoneOffset.ofTotalSeconds(this._standardOffsetInSeconds(instant
|
|
232
|
+
return ZoneOffset.ofTotalSeconds(this._standardOffsetInSeconds(epochMilliOf(instant)));
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
_standardOffsetInSeconds(epochMilli){
|
|
@@ -256,7 +256,7 @@ export class TzdbZoneRules extends ZoneRules{
|
|
|
256
256
|
* @throws {Error} if the tz data of the zone has no standard offsets
|
|
257
257
|
*/
|
|
258
258
|
daylightSavings(instant){
|
|
259
|
-
const epochMilli = instant
|
|
259
|
+
const epochMilli = epochMilliOf(instant);
|
|
260
260
|
const index = binarySearch(this._tzdbInfo.untils, epochMilli);
|
|
261
261
|
return Duration.ofSeconds(this._offsetByIndexInSeconds(index) - this._standardOffsetInSeconds(epochMilli));
|
|
262
262
|
}
|
|
@@ -306,7 +306,7 @@ export class TzdbZoneRules extends ZoneRules{
|
|
|
306
306
|
const indices = this._transitionIndices();
|
|
307
307
|
const untils = this._tzdbInfo.untils;
|
|
308
308
|
// transitions are at whole milliseconds, so "after the instant" equals "after its truncated milli"
|
|
309
|
-
const epochMilli = instant
|
|
309
|
+
const epochMilli = epochMilliOf(instant);
|
|
310
310
|
const k = firstIndexWhere(indices, (i) => untils[i] > epochMilli);
|
|
311
311
|
return k < indices.length ? this._createTransition(indices[k]) : null;
|
|
312
312
|
}
|
|
@@ -327,7 +327,7 @@ export class TzdbZoneRules extends ZoneRules{
|
|
|
327
327
|
const untils = this._tzdbInfo.untils;
|
|
328
328
|
// round up to the next milli if the instant has a fraction of a milli,
|
|
329
329
|
// so that a transition at the truncated milli counts as before the instant
|
|
330
|
-
const epochMilli = instant
|
|
330
|
+
const epochMilli = epochMilliOf(instant) + (instant.nano() % 1000000 > 0 ? 1 : 0);
|
|
331
331
|
const k = firstIndexWhere(indices, (i) => untils[i] >= epochMilli);
|
|
332
332
|
return k > 0 ? this._createTransition(indices[k - 1]) : null;
|
|
333
333
|
}
|
|
@@ -479,16 +479,26 @@ function ldtBinarySearch(array, value) {
|
|
|
479
479
|
return hi;
|
|
480
480
|
}
|
|
481
481
|
|
|
482
|
+
// the offset is stored in minutes, with seconds as a base 60 fraction; multiplying it back can
|
|
483
|
+
// give a value just below the whole second (e.g. 65.35 * 60 = 3920.9999...), so round it
|
|
482
484
|
function offsetInSeconds(tzdbOffset){
|
|
483
|
-
return
|
|
485
|
+
return Math.round(+tzdbOffset*60);
|
|
484
486
|
}
|
|
485
487
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
488
|
+
// beyond this epoch second, Instant.toEpochMilli() overflows; far outside the tz data
|
|
489
|
+
const MAX_EPOCH_SECOND_FOR_MILLIS = Math.floor(Number.MAX_SAFE_INTEGER / 1000) - 1;
|
|
490
|
+
|
|
491
|
+
// the epoch milli of the instant, or +/-Infinity for an instant too far out for an epoch milli
|
|
492
|
+
// (e.g. Instant.MAX); infinities compare with the untils of the tz data like any far instant
|
|
493
|
+
function epochMilliOf(instant) {
|
|
494
|
+
const epochSecond = instant.epochSecond();
|
|
495
|
+
if (epochSecond > MAX_EPOCH_SECOND_FOR_MILLIS) {
|
|
496
|
+
return Infinity;
|
|
497
|
+
}
|
|
498
|
+
if (epochSecond < -MAX_EPOCH_SECOND_FOR_MILLIS) {
|
|
499
|
+
return -Infinity;
|
|
491
500
|
}
|
|
501
|
+
return instant.toEpochMilli();
|
|
492
502
|
}
|
|
493
503
|
|
|
494
504
|
// modified bin-search, to always find existing indices for non-empty arrays
|