bizdays-toolkit 0.32.4 → 0.32.5
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/date.d.ts +9 -3
- package/dist/core/date.js +6 -3
- package/dist/core/diagnose.js +4 -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.5] - 2026-11-18
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Calculations that step through days are faster: turning a day number back into a date no longer parses the date string it has just built (the year is still checked against 1000–9999), and the option diagnostics work out the days a recurring rule matches only when two rules are compared. Searching, adding and counting business days, ranges of days and the option diagnostics are faster. Results, exceptions and diagnostics are unchanged
|
|
14
|
+
|
|
9
15
|
## [0.32.4] - 2026-11-18
|
|
10
16
|
|
|
11
17
|
### Fixed
|
|
@@ -1032,7 +1038,8 @@ This version rebuilds the `redundant` diagnostic so that the reported rules can
|
|
|
1032
1038
|
|
|
1033
1039
|
- 日本: 2026 年 2 月の官報(2027 年の春分・秋分の日)まで反映(`dataVersion: "2026-02"`、`confirmedThrough: 2027`)
|
|
1034
1040
|
|
|
1035
|
-
[Unreleased]: https://github.com/inohan77/bizdays-toolkit/compare/v0.32.
|
|
1041
|
+
[Unreleased]: https://github.com/inohan77/bizdays-toolkit/compare/v0.32.5...HEAD
|
|
1042
|
+
[0.32.5]: https://github.com/inohan77/bizdays-toolkit/compare/v0.32.4...v0.32.5
|
|
1036
1043
|
[0.32.4]: https://github.com/inohan77/bizdays-toolkit/compare/v0.32.3...v0.32.4
|
|
1037
1044
|
[0.32.3]: https://github.com/inohan77/bizdays-toolkit/compare/v0.32.2...v0.32.3
|
|
1038
1045
|
[0.32.2]: https://github.com/inohan77/bizdays-toolkit/compare/v0.32.1...v0.32.2
|
package/dist/core/date.d.ts
CHANGED
|
@@ -25,15 +25,21 @@ export declare function parseDate(value: string): {
|
|
|
25
25
|
* @public
|
|
26
26
|
*/
|
|
27
27
|
export declare function isValidDate(input: unknown): input is DateString;
|
|
28
|
-
/**
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* 年月日から "YYYY-MM-DD" を作る(範囲外なら RangeError)。exists なら、実在する年月日として解析し直さず、parseDate の
|
|
30
|
+
* 直前 1 件の記憶に入れる(続けて同じ文字列を解析するため。decisions.md の 16 番)
|
|
31
|
+
*/
|
|
32
|
+
export declare function formatDate(year: number, month: number, day: number, exists?: boolean): DateString;
|
|
30
33
|
/** うるう年か */
|
|
31
34
|
export declare function isLeapYear(year: number): boolean;
|
|
32
35
|
/** その月の日数 */
|
|
33
36
|
export declare function lengthOfMonth(year: number, month: number): number;
|
|
34
37
|
/** 1970-01-01 からの日数 */
|
|
35
38
|
export declare function toDayNumber(date: DateString): number;
|
|
36
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* 1970-01-01 からの日数を "YYYY-MM-DD" に戻す。日数から作る年月日は必ず実在するので、文字列を解析し直して検証しない
|
|
41
|
+
* (年の範囲だけを確かめる。探索・期間の数え上げ・診断の走査が 1 日ごとに呼ぶ)
|
|
42
|
+
*/
|
|
37
43
|
export declare function fromDayNumber(dayNumber: number): DateString;
|
|
38
44
|
/**
|
|
39
45
|
* n 日後(負なら前)の日付。
|
package/dist/core/date.js
CHANGED
|
@@ -31,12 +31,15 @@ export function isValidDate(input) {
|
|
|
31
31
|
return false;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
export function formatDate(year, month, day) {
|
|
34
|
+
export function formatDate(year, month, day, exists) {
|
|
35
35
|
if (!Number.isInteger(year) || year < 1000 || year > 9999) {
|
|
36
36
|
throw rangeError("out-of-range", `Year out of range (1000-9999): ${year}`);
|
|
37
37
|
}
|
|
38
38
|
const s = `${year}-${String(month).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
|
|
39
|
-
|
|
39
|
+
if (!exists)
|
|
40
|
+
parseDate(s);
|
|
41
|
+
else
|
|
42
|
+
[lastValue, lastParts] = [s, Object.freeze({ year, month, day })];
|
|
40
43
|
return s;
|
|
41
44
|
}
|
|
42
45
|
export function isLeapYear(year) {
|
|
@@ -56,7 +59,7 @@ export function toDayNumber(date) {
|
|
|
56
59
|
}
|
|
57
60
|
export function fromDayNumber(dayNumber) {
|
|
58
61
|
const d = new Date(dayNumber * MS_PER_DAY);
|
|
59
|
-
return formatDate(d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate());
|
|
62
|
+
return formatDate(d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate(), true);
|
|
60
63
|
}
|
|
61
64
|
export function addDays(date, n) {
|
|
62
65
|
if (!Number.isInteger(n)) {
|
package/dist/core/diagnose.js
CHANGED
|
@@ -545,7 +545,9 @@ function analyzeRules(c, compiled, isCalendar, unsure = () => false) {
|
|
|
545
545
|
c.warning("shadowed", rule.path, `This rule is never used: the earlier rule ${annual[k].path} covers all of its days`, annual[k].path);
|
|
546
546
|
});
|
|
547
547
|
const noBits = new Uint8Array(PATTERN_DAYS);
|
|
548
|
-
const recurringBits =
|
|
548
|
+
const recurringBits = [];
|
|
549
|
+
const bitsOf = (j) => (recurringBits[j] ??=
|
|
550
|
+
recurring[j].businessDays !== null ? noBits : patternBits(recurring[j]));
|
|
549
551
|
const holidayOfSafe = (date) => {
|
|
550
552
|
try {
|
|
551
553
|
return lookup.holidayOfDate(date);
|
|
@@ -615,7 +617,6 @@ function analyzeRules(c, compiled, isCalendar, unsure = () => false) {
|
|
|
615
617
|
a.skipWeekdays.size === b.skipWeekdays.size &&
|
|
616
618
|
[...a.skipWeekdays].every((w) => b.skipWeekdays.has(w));
|
|
617
619
|
recurring.forEach((rule, j) => {
|
|
618
|
-
const bits = recurringBits[j];
|
|
619
620
|
const holidayBased = isHolidayBasedRule(rule);
|
|
620
621
|
const businessDayBased = rule.businessDays !== null;
|
|
621
622
|
const matches = holidayBased
|
|
@@ -688,7 +689,7 @@ function analyzeRules(c, compiled, isCalendar, unsure = () => false) {
|
|
|
688
689
|
r.businessDays === null &&
|
|
689
690
|
r.cycle === null &&
|
|
690
691
|
intervalCovers(r, rule) &&
|
|
691
|
-
isSubset(
|
|
692
|
+
isSubset(bitsOf(j), bitsOf(i))));
|
|
692
693
|
if (k < 0)
|
|
693
694
|
return;
|
|
694
695
|
unused.add(rule);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bizdays-toolkit",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.5",
|
|
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",
|