bizdays-toolkit 0.32.2 → 0.32.3
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/CHANGELOG.md +8 -1
- package/dist/core/input.js +22 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,12 @@ Entries from 0.31.0 are in English. Earlier entries remain in Japanese (their **
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.32.3] - 2026-11-17
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- The cache of time zone formatters no longer grows with every spelling of a time zone (`"Asia/Tokyo"`, `"asia/tokyo"`, `"+09:00"`, `"+0900"`, ...). A server that passed time zone strings from requests to `createCalendar`, `createSchedule` or `toDateString` could run out of memory: each new spelling kept a formatter of the runtime's `Intl`, outside the JavaScript heap. A formatter is now kept for each name that `Intl` reports, the spellings are remembered up to 1,000 and then forgotten, and offsets from UTC are read without a formatter of their own (design decisions 16). Results are unchanged. For an instant after the year 10000 in UTC, the message of the `out-of-range` exception is now `Instant out of range (1000-9999)` in every time zone, as before the year 999; the code is unchanged
|
|
14
|
+
|
|
9
15
|
## [0.32.2] - 2026-11-15
|
|
10
16
|
|
|
11
17
|
### Fixed
|
|
@@ -1014,7 +1020,8 @@ This version rebuilds the `redundant` diagnostic so that the reported rules can
|
|
|
1014
1020
|
|
|
1015
1021
|
- 日本: 2026 年 2 月の官報(2027 年の春分・秋分の日)まで反映(`dataVersion: "2026-02"`、`confirmedThrough: 2027`)
|
|
1016
1022
|
|
|
1017
|
-
[Unreleased]: https://github.com/inohan77/bizdays-toolkit/compare/v0.32.
|
|
1023
|
+
[Unreleased]: https://github.com/inohan77/bizdays-toolkit/compare/v0.32.3...HEAD
|
|
1024
|
+
[0.32.3]: https://github.com/inohan77/bizdays-toolkit/compare/v0.32.2...v0.32.3
|
|
1018
1025
|
[0.32.2]: https://github.com/inohan77/bizdays-toolkit/compare/v0.32.1...v0.32.2
|
|
1019
1026
|
[0.32.1]: https://github.com/inohan77/bizdays-toolkit/compare/v0.32.0...v0.32.1
|
|
1020
1027
|
[0.32.0]: https://github.com/inohan77/bizdays-toolkit/compare/v0.31.9...v0.32.0
|
package/dist/core/input.js
CHANGED
|
@@ -2,6 +2,8 @@ import { formatDate, parseDate } from "./date.js";
|
|
|
2
2
|
import { describeValue, rangeError, typeError } from "./errors.js";
|
|
3
3
|
const DATETIME_RE = /^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(Z|[+-]\d{2}:?\d{2})?$/i;
|
|
4
4
|
const formatters = new Map();
|
|
5
|
+
const zoneNames = new Map();
|
|
6
|
+
const OFFSET_ZONE_RE = /^([+-])(\d\d):(\d\d)$/;
|
|
5
7
|
function formatterFor(timeZone) {
|
|
6
8
|
let f = formatters.get(timeZone);
|
|
7
9
|
if (!f) {
|
|
@@ -18,12 +20,23 @@ function formatterFor(timeZone) {
|
|
|
18
20
|
}
|
|
19
21
|
return f;
|
|
20
22
|
}
|
|
23
|
+
function zoneNameOf(timeZone) {
|
|
24
|
+
const key = timeZone.replace(/[A-Z]+/g, (s) => s.toLowerCase());
|
|
25
|
+
let name = zoneNames.get(key);
|
|
26
|
+
if (name === undefined) {
|
|
27
|
+
name = new Intl.DateTimeFormat("en-US", { timeZone }).resolvedOptions().timeZone;
|
|
28
|
+
if (zoneNames.size >= 1000)
|
|
29
|
+
zoneNames.clear();
|
|
30
|
+
zoneNames.set(key, name).set(name, name);
|
|
31
|
+
}
|
|
32
|
+
return name;
|
|
33
|
+
}
|
|
21
34
|
export function validateTimeZone(timeZone) {
|
|
22
35
|
if (typeof timeZone !== "string" || timeZone === "") {
|
|
23
36
|
throw rangeError("invalid-time-zone", `Invalid time zone: ${describeValue(timeZone)}`);
|
|
24
37
|
}
|
|
25
38
|
try {
|
|
26
|
-
return
|
|
39
|
+
return zoneNameOf(timeZone);
|
|
27
40
|
}
|
|
28
41
|
catch {
|
|
29
42
|
throw rangeError("invalid-time-zone", `Invalid time zone: ${describeValue(timeZone)}`);
|
|
@@ -51,7 +64,12 @@ export function distinctTimeZones(zones) {
|
|
|
51
64
|
return out;
|
|
52
65
|
}
|
|
53
66
|
function wallParts(epochMilliseconds, timeZone) {
|
|
54
|
-
const
|
|
67
|
+
const zone = zoneNames.get(timeZone) === timeZone ? timeZone : zoneNameOf(timeZone);
|
|
68
|
+
const offset = OFFSET_ZONE_RE.exec(zone);
|
|
69
|
+
const parts = formatterFor(offset ? "UTC" : zone).formatToParts(new Date(epochMilliseconds +
|
|
70
|
+
(offset
|
|
71
|
+
? (offset[1] === "-" ? -60_000 : 60_000) * (Number(offset[2]) * 60 + Number(offset[3]))
|
|
72
|
+
: 0)));
|
|
55
73
|
const get = (type) => {
|
|
56
74
|
const p = parts.find((x) => x.type === type);
|
|
57
75
|
if (!p)
|
|
@@ -72,7 +90,8 @@ export function instantToCivil(epochMilliseconds, timeZone) {
|
|
|
72
90
|
if (Math.abs(epochMilliseconds) > 8.64e15) {
|
|
73
91
|
throw rangeError("out-of-range", "Instant out of range (1000-9999)");
|
|
74
92
|
}
|
|
75
|
-
|
|
93
|
+
const utcYear = new Date(epochMilliseconds).getUTCFullYear();
|
|
94
|
+
if (utcYear < 999 || utcYear > 10000) {
|
|
76
95
|
throw rangeError("out-of-range", "Instant out of range (1000-9999)");
|
|
77
96
|
}
|
|
78
97
|
const { year, month, day, hour, minute } = wallParts(epochMilliseconds, timeZone);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bizdays-toolkit",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.3",
|
|
4
4
|
"description": "Holidays, business-day calendar and day-by-day schedules (e.g. store hours) with time zone support. Japanese holidays verified against the Cabinet Office data; UK bank holidays (England, Wales, Scotland, Northern Ireland) verified against GOV.UK and The Gazette; French public holidays (metropole, Alsace-Moselle) verified against data.gouv.fr; Singapore public holidays verified against data.gov.sg. / 祝日と営業日のカレンダー(タイムゾーン対応・日本の祝日は内閣府、英国の bank holidays は GOV.UK と The Gazette、フランスの祝日は data.gouv.fr、シンガポールの祝日は data.gov.sg のデータで全日照合)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bank-holidays",
|