@intech-software/chronera 0.1.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/LICENSE +190 -0
- package/README.md +6644 -0
- package/dist/calendar/buddhist/adapter.d.ts +2 -0
- package/dist/calendar/buddhist/adapter.js +33 -0
- package/dist/calendar/buddhist/adapter.js.map +1 -0
- package/dist/calendar/buddhist/constants.d.ts +3 -0
- package/dist/calendar/buddhist/constants.js +14 -0
- package/dist/calendar/buddhist/constants.js.map +1 -0
- package/dist/calendar/buddhist/index.d.ts +3 -0
- package/dist/calendar/buddhist/index.js +4 -0
- package/dist/calendar/buddhist/index.js.map +1 -0
- package/dist/calendar/buddhist/validator.d.ts +4 -0
- package/dist/calendar/buddhist/validator.js +60 -0
- package/dist/calendar/buddhist/validator.js.map +1 -0
- package/dist/calendar/gregory/absolute-day.d.ts +12 -0
- package/dist/calendar/gregory/absolute-day.js +14 -0
- package/dist/calendar/gregory/absolute-day.js.map +1 -0
- package/dist/calendar/gregory/adapter.d.ts +3 -0
- package/dist/calendar/gregory/adapter.js +93 -0
- package/dist/calendar/gregory/adapter.js.map +1 -0
- package/dist/calendar/gregory/constants.d.ts +3 -0
- package/dist/calendar/gregory/constants.js +18 -0
- package/dist/calendar/gregory/constants.js.map +1 -0
- package/dist/calendar/gregory/index.d.ts +4 -0
- package/dist/calendar/gregory/index.js +5 -0
- package/dist/calendar/gregory/index.js.map +1 -0
- package/dist/calendar/gregory/leap-year.d.ts +1 -0
- package/dist/calendar/gregory/leap-year.js +2 -0
- package/dist/calendar/gregory/leap-year.js.map +1 -0
- package/dist/calendar/gregory/validator.d.ts +2 -0
- package/dist/calendar/gregory/validator.js +45 -0
- package/dist/calendar/gregory/validator.js.map +1 -0
- package/dist/calendar/hijri/civil-adapter.d.ts +12 -0
- package/dist/calendar/hijri/civil-adapter.js +132 -0
- package/dist/calendar/hijri/civil-adapter.js.map +1 -0
- package/dist/calendar/hijri/index.d.ts +3 -0
- package/dist/calendar/hijri/index.js +4 -0
- package/dist/calendar/hijri/index.js.map +1 -0
- package/dist/calendar/hijri/tabular-adapter.d.ts +4 -0
- package/dist/calendar/hijri/tabular-adapter.js +79 -0
- package/dist/calendar/hijri/tabular-adapter.js.map +1 -0
- package/dist/calendar/hijri/umm-al-qura-adapter.d.ts +4 -0
- package/dist/calendar/hijri/umm-al-qura-adapter.js +27 -0
- package/dist/calendar/hijri/umm-al-qura-adapter.js.map +1 -0
- package/dist/calendar/index.d.ts +13 -0
- package/dist/calendar/index.js +12 -0
- package/dist/calendar/index.js.map +1 -0
- package/dist/calendar/indian/adapter.d.ts +2 -0
- package/dist/calendar/indian/adapter.js +66 -0
- package/dist/calendar/indian/adapter.js.map +1 -0
- package/dist/calendar/indian/constants.d.ts +5 -0
- package/dist/calendar/indian/constants.js +43 -0
- package/dist/calendar/indian/constants.js.map +1 -0
- package/dist/calendar/indian/index.d.ts +3 -0
- package/dist/calendar/indian/index.js +4 -0
- package/dist/calendar/indian/index.js.map +1 -0
- package/dist/calendar/indian/validator.d.ts +6 -0
- package/dist/calendar/indian/validator.js +65 -0
- package/dist/calendar/indian/validator.js.map +1 -0
- package/dist/calendar/japanese/adapter.d.ts +3 -0
- package/dist/calendar/japanese/adapter.js +63 -0
- package/dist/calendar/japanese/adapter.js.map +1 -0
- package/dist/calendar/japanese/constants.d.ts +17 -0
- package/dist/calendar/japanese/constants.js +85 -0
- package/dist/calendar/japanese/constants.js.map +1 -0
- package/dist/calendar/japanese/index.d.ts +3 -0
- package/dist/calendar/japanese/index.js +4 -0
- package/dist/calendar/japanese/index.js.map +1 -0
- package/dist/calendar/japanese/validator.d.ts +5 -0
- package/dist/calendar/japanese/validator.js +76 -0
- package/dist/calendar/japanese/validator.js.map +1 -0
- package/dist/calendar/persian/adapter.d.ts +2 -0
- package/dist/calendar/persian/adapter.js +42 -0
- package/dist/calendar/persian/adapter.js.map +1 -0
- package/dist/calendar/persian/constants.d.ts +5 -0
- package/dist/calendar/persian/constants.js +43 -0
- package/dist/calendar/persian/constants.js.map +1 -0
- package/dist/calendar/persian/index.d.ts +4 -0
- package/dist/calendar/persian/index.js +5 -0
- package/dist/calendar/persian/index.js.map +1 -0
- package/dist/calendar/persian/math.d.ts +24 -0
- package/dist/calendar/persian/math.js +109 -0
- package/dist/calendar/persian/math.js.map +1 -0
- package/dist/calendar/persian/validator.d.ts +4 -0
- package/dist/calendar/persian/validator.js +52 -0
- package/dist/calendar/persian/validator.js.map +1 -0
- package/dist/calendar/registry.d.ts +9 -0
- package/dist/calendar/registry.js +119 -0
- package/dist/calendar/registry.js.map +1 -0
- package/dist/calendar/roc/adapter.d.ts +2 -0
- package/dist/calendar/roc/adapter.js +47 -0
- package/dist/calendar/roc/adapter.js.map +1 -0
- package/dist/calendar/roc/constants.d.ts +6 -0
- package/dist/calendar/roc/constants.js +34 -0
- package/dist/calendar/roc/constants.js.map +1 -0
- package/dist/calendar/roc/index.d.ts +3 -0
- package/dist/calendar/roc/index.js +4 -0
- package/dist/calendar/roc/index.js.map +1 -0
- package/dist/calendar/roc/validator.d.ts +4 -0
- package/dist/calendar/roc/validator.js +52 -0
- package/dist/calendar/roc/validator.js.map +1 -0
- package/dist/calendar/types.d.ts +34 -0
- package/dist/calendar/types.js +2 -0
- package/dist/calendar/types.js.map +1 -0
- package/dist/core/absolute-day.d.ts +8 -0
- package/dist/core/absolute-day.js +39 -0
- package/dist/core/absolute-day.js.map +1 -0
- package/dist/core/calendar-date.d.ts +11 -0
- package/dist/core/calendar-date.js +37 -0
- package/dist/core/calendar-date.js.map +1 -0
- package/dist/core/day-of-year.d.ts +16 -0
- package/dist/core/day-of-year.js +30 -0
- package/dist/core/day-of-year.js.map +1 -0
- package/dist/core/duration.d.ts +2 -0
- package/dist/core/duration.js +31 -0
- package/dist/core/duration.js.map +1 -0
- package/dist/core/fiscal.d.ts +31 -0
- package/dist/core/fiscal.js +45 -0
- package/dist/core/fiscal.js.map +1 -0
- package/dist/core/gregorian-math.d.ts +4 -0
- package/dist/core/gregorian-math.js +30 -0
- package/dist/core/gregorian-math.js.map +1 -0
- package/dist/core/instant.d.ts +6 -0
- package/dist/core/instant.js +26 -0
- package/dist/core/instant.js.map +1 -0
- package/dist/core/integer.d.ts +1 -0
- package/dist/core/integer.js +7 -0
- package/dist/core/integer.js.map +1 -0
- package/dist/core/iso-week.d.ts +19 -0
- package/dist/core/iso-week.js +41 -0
- package/dist/core/iso-week.js.map +1 -0
- package/dist/core/julian-day.d.ts +26 -0
- package/dist/core/julian-day.js +35 -0
- package/dist/core/julian-day.js.map +1 -0
- package/dist/core/local-date-time.d.ts +2 -0
- package/dist/core/local-date-time.js +15 -0
- package/dist/core/local-date-time.js.map +1 -0
- package/dist/core/local-date.d.ts +2 -0
- package/dist/core/local-date.js +22 -0
- package/dist/core/local-date.js.map +1 -0
- package/dist/core/local-time.d.ts +2 -0
- package/dist/core/local-time.js +28 -0
- package/dist/core/local-time.js.map +1 -0
- package/dist/core/range.d.ts +2 -0
- package/dist/core/range.js +9 -0
- package/dist/core/range.js.map +1 -0
- package/dist/create-chronera.d.ts +2 -0
- package/dist/create-chronera.js +59 -0
- package/dist/create-chronera.js.map +1 -0
- package/dist/errors/error-codes.d.ts +1 -0
- package/dist/errors/error-codes.js +2 -0
- package/dist/errors/error-codes.js.map +1 -0
- package/dist/errors/errors.d.ts +16 -0
- package/dist/errors/errors.js +22 -0
- package/dist/errors/errors.js.map +1 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +2 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/format/format-date-range.d.ts +2 -0
- package/dist/format/format-date-range.js +89 -0
- package/dist/format/format-date-range.js.map +1 -0
- package/dist/format/format-date-time.d.ts +2 -0
- package/dist/format/format-date-time.js +51 -0
- package/dist/format/format-date-time.js.map +1 -0
- package/dist/format/format-date.d.ts +4 -0
- package/dist/format/format-date.js +103 -0
- package/dist/format/format-date.js.map +1 -0
- package/dist/format/format-pattern.d.ts +4 -0
- package/dist/format/format-pattern.js +266 -0
- package/dist/format/format-pattern.js.map +1 -0
- package/dist/format/format-relative.d.ts +2 -0
- package/dist/format/format-relative.js +93 -0
- package/dist/format/format-relative.js.map +1 -0
- package/dist/format/format-time.d.ts +2 -0
- package/dist/format/format-time.js +48 -0
- package/dist/format/format-time.js.map +1 -0
- package/dist/format/index.d.ts +13 -0
- package/dist/format/index.js +12 -0
- package/dist/format/index.js.map +1 -0
- package/dist/format/pattern-scanner.d.ts +8 -0
- package/dist/format/pattern-scanner.js +102 -0
- package/dist/format/pattern-scanner.js.map +1 -0
- package/dist/format/presets/japanese-official.d.ts +8 -0
- package/dist/format/presets/japanese-official.js +39 -0
- package/dist/format/presets/japanese-official.js.map +1 -0
- package/dist/format/presets/taiwan-official.d.ts +6 -0
- package/dist/format/presets/taiwan-official.js +23 -0
- package/dist/format/presets/taiwan-official.js.map +1 -0
- package/dist/format/presets/thai-official.d.ts +2 -0
- package/dist/format/presets/thai-official.js +45 -0
- package/dist/format/presets/thai-official.js.map +1 -0
- package/dist/format/presets/types.d.ts +2 -0
- package/dist/format/presets/types.js +2 -0
- package/dist/format/presets/types.js.map +1 -0
- package/dist/format/presets/world-locales.d.ts +29 -0
- package/dist/format/presets/world-locales.js +330 -0
- package/dist/format/presets/world-locales.js.map +1 -0
- package/dist/format/resolve-date-input.d.ts +9 -0
- package/dist/format/resolve-date-input.js +93 -0
- package/dist/format/resolve-date-input.js.map +1 -0
- package/dist/format/rfc2822.d.ts +17 -0
- package/dist/format/rfc2822.js +59 -0
- package/dist/format/rfc2822.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/engine.d.ts +8 -0
- package/dist/internal/engine.js +11 -0
- package/dist/internal/engine.js.map +1 -0
- package/dist/locale/numbering-system.d.ts +4 -0
- package/dist/locale/numbering-system.js +133 -0
- package/dist/locale/numbering-system.js.map +1 -0
- package/dist/locale/resolve-locale.d.ts +7 -0
- package/dist/locale/resolve-locale.js +51 -0
- package/dist/locale/resolve-locale.js.map +1 -0
- package/dist/locale/types.d.ts +1 -0
- package/dist/locale/types.js +2 -0
- package/dist/locale/types.js.map +1 -0
- package/dist/operations/arithmetic.d.ts +4 -0
- package/dist/operations/arithmetic.js +13 -0
- package/dist/operations/arithmetic.js.map +1 -0
- package/dist/operations/compare.d.ts +5 -0
- package/dist/operations/compare.js +50 -0
- package/dist/operations/compare.js.map +1 -0
- package/dist/operations/convert-calendar-date.d.ts +4 -0
- package/dist/operations/convert-calendar-date.js +54 -0
- package/dist/operations/convert-calendar-date.js.map +1 -0
- package/dist/operations/day-of-year.d.ts +7 -0
- package/dist/operations/day-of-year.js +29 -0
- package/dist/operations/day-of-year.js.map +1 -0
- package/dist/operations/fiscal.d.ts +5 -0
- package/dist/operations/fiscal.js +25 -0
- package/dist/operations/fiscal.js.map +1 -0
- package/dist/operations/iso-week.d.ts +9 -0
- package/dist/operations/iso-week.js +29 -0
- package/dist/operations/iso-week.js.map +1 -0
- package/dist/operations/julian-day.d.ts +6 -0
- package/dist/operations/julian-day.js +37 -0
- package/dist/operations/julian-day.js.map +1 -0
- package/dist/operations/validate.d.ts +10 -0
- package/dist/operations/validate.js +55 -0
- package/dist/operations/validate.js.map +1 -0
- package/dist/parse/field-normalizer.d.ts +1 -0
- package/dist/parse/field-normalizer.js +5 -0
- package/dist/parse/field-normalizer.js.map +1 -0
- package/dist/parse/index.d.ts +4 -0
- package/dist/parse/index.js +4 -0
- package/dist/parse/index.js.map +1 -0
- package/dist/parse/parse-instant.d.ts +2 -0
- package/dist/parse/parse-instant.js +97 -0
- package/dist/parse/parse-instant.js.map +1 -0
- package/dist/parse/parse-local-date.d.ts +2 -0
- package/dist/parse/parse-local-date.js +31 -0
- package/dist/parse/parse-local-date.js.map +1 -0
- package/dist/parse/pattern-parser.d.ts +2 -0
- package/dist/parse/pattern-parser.js +150 -0
- package/dist/parse/pattern-parser.js.map +1 -0
- package/dist/parse/safe-parse.d.ts +3 -0
- package/dist/parse/safe-parse.js +46 -0
- package/dist/parse/safe-parse.js.map +1 -0
- package/dist/public-types.d.ts +209 -0
- package/dist/public-types.js +2 -0
- package/dist/public-types.js.map +1 -0
- package/dist/runtime/bounded-lru.d.ts +11 -0
- package/dist/runtime/bounded-lru.js +42 -0
- package/dist/runtime/bounded-lru.js.map +1 -0
- package/dist/runtime/capabilities.d.ts +5 -0
- package/dist/runtime/capabilities.js +61 -0
- package/dist/runtime/capabilities.js.map +1 -0
- package/dist/runtime/intl-date-time.d.ts +11 -0
- package/dist/runtime/intl-date-time.js +38 -0
- package/dist/runtime/intl-date-time.js.map +1 -0
- package/dist/runtime/intl-number.d.ts +7 -0
- package/dist/runtime/intl-number.js +35 -0
- package/dist/runtime/intl-number.js.map +1 -0
- package/dist/runtime/intl-relative-time.d.ts +7 -0
- package/dist/runtime/intl-relative-time.js +35 -0
- package/dist/runtime/intl-relative-time.js.map +1 -0
- package/dist/runtime/timezone.d.ts +14 -0
- package/dist/runtime/timezone.js +95 -0
- package/dist/runtime/timezone.js.map +1 -0
- package/package.json +155 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { absoluteDayFromGregorianFields, gregorianFieldsFromAbsoluteDay, } from "../../core/absolute-day.js";
|
|
2
|
+
import { formatGregorianMonthCode, parseGregorianMonthCode, } from "../../core/gregorian-math.js";
|
|
3
|
+
import { ChroneraError } from "../../errors/errors.js";
|
|
4
|
+
import { ROC_IDENTITY, ROC_OFFSET, ROC_START_ABSOLUTE_DAY, } from "./constants.js";
|
|
5
|
+
import { rocValidator } from "./validator.js";
|
|
6
|
+
export const rocAdapter = {
|
|
7
|
+
identity: ROC_IDENTITY,
|
|
8
|
+
validator: rocValidator,
|
|
9
|
+
converter: {
|
|
10
|
+
identity: ROC_IDENTITY,
|
|
11
|
+
toAbsoluteDay(date) {
|
|
12
|
+
const month = parseGregorianMonthCode(date.monthCode);
|
|
13
|
+
if (month === null) {
|
|
14
|
+
throw new ChroneraError("CHRONERA_INVALID_DATE", `Invalid monthCode: "${date.monthCode}". Expected M01-M12.`);
|
|
15
|
+
}
|
|
16
|
+
if (date.year < 1) {
|
|
17
|
+
throw new ChroneraError("CHRONERA_OUT_OF_RANGE", `ROC calendar supports years >= 1. Received year ${date.year}.`);
|
|
18
|
+
}
|
|
19
|
+
const gregorianYear = date.year + ROC_OFFSET;
|
|
20
|
+
if (gregorianYear > 9999) {
|
|
21
|
+
throw new ChroneraError("CHRONERA_OUT_OF_RANGE", `ROC date exceeds maximum Gregorian year 9999.`);
|
|
22
|
+
}
|
|
23
|
+
return absoluteDayFromGregorianFields(gregorianYear, month, date.day);
|
|
24
|
+
},
|
|
25
|
+
fromAbsoluteDay(absoluteDay) {
|
|
26
|
+
if (absoluteDay < ROC_START_ABSOLUTE_DAY) {
|
|
27
|
+
throw new ChroneraError("CHRONERA_OUT_OF_RANGE", `Date is before ROC calendar epoch (1912-01-01).`);
|
|
28
|
+
}
|
|
29
|
+
const fields = gregorianFieldsFromAbsoluteDay(absoluteDay);
|
|
30
|
+
if (fields.year > 9999) {
|
|
31
|
+
throw new ChroneraError("CHRONERA_OUT_OF_RANGE", `Date exceeds maximum supported year 9999.`);
|
|
32
|
+
}
|
|
33
|
+
const rocYear = fields.year - ROC_OFFSET;
|
|
34
|
+
return {
|
|
35
|
+
kind: "calendar-date",
|
|
36
|
+
calendar: "roc",
|
|
37
|
+
era: "roc",
|
|
38
|
+
eraYear: rocYear,
|
|
39
|
+
year: rocYear,
|
|
40
|
+
monthCode: formatGregorianMonthCode(fields.month),
|
|
41
|
+
month: fields.month,
|
|
42
|
+
day: fields.day,
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../src/calendar/roc/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9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MAAM,MAAM,GAAG,8BAA8B,CAAC,WAAW,CAAC,CAAC;YAC3D,IAAI,MAAM,CAAC,IAAI,GAAG,IAAI,EAAE,CAAC;gBACvB,MAAM,IAAI,aAAa,CACrB,uBAAuB,EACvB,2CAA2C,CAC5C,CAAC;YACJ,CAAC;YAED,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC;YACzC,OAAO;gBACL,IAAI,EAAE,eAAe;gBACrB,QAAQ,EAAE,KAAK;gBACf,GAAG,EAAE,KAAK;gBACV,OAAO,EAAE,OAAO;gBAChB,IAAI,EAAE,OAAO;gBACb,SAAS,EAAE,wBAAwB,CAAC,MAAM,CAAC,KAAK,CAAC;gBACjD,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,GAAG,EAAE,MAAM,CAAC,GAAG;aAChB,CAAC;QACJ,CAAC;KACF;CACF,CAAC","sourcesContent":["import {\n absoluteDayFromGregorianFields,\n gregorianFieldsFromAbsoluteDay,\n} from \"../../core/absolute-day.js\";\nimport {\n formatGregorianMonthCode,\n parseGregorianMonthCode,\n} from \"../../core/gregorian-math.js\";\nimport { ChroneraError } from \"../../errors/errors.js\";\nimport {\n ROC_IDENTITY,\n ROC_OFFSET,\n ROC_START_ABSOLUTE_DAY,\n} from \"./constants.js\";\nimport { rocValidator } from \"./validator.js\";\n\nimport type { CalendarAdapter } from \"../types.js\";\nimport type { CalendarDate } from \"../../public-types.js\";\n\nexport const rocAdapter: CalendarAdapter = {\n identity: ROC_IDENTITY,\n validator: rocValidator,\n converter: {\n identity: ROC_IDENTITY,\n toAbsoluteDay(date: CalendarDate): number {\n const month = parseGregorianMonthCode(date.monthCode);\n if (month === null) {\n throw new ChroneraError(\n \"CHRONERA_INVALID_DATE\",\n `Invalid monthCode: \"${date.monthCode}\". Expected M01-M12.`,\n );\n }\n\n if (date.year < 1) {\n throw new ChroneraError(\n \"CHRONERA_OUT_OF_RANGE\",\n `ROC calendar supports years >= 1. Received year ${date.year}.`,\n );\n }\n\n const gregorianYear = date.year + ROC_OFFSET;\n if (gregorianYear > 9999) {\n throw new ChroneraError(\n \"CHRONERA_OUT_OF_RANGE\",\n `ROC date exceeds maximum Gregorian year 9999.`,\n );\n }\n\n return absoluteDayFromGregorianFields(gregorianYear, month, date.day);\n },\n\n fromAbsoluteDay(absoluteDay: number): CalendarDate {\n if (absoluteDay < ROC_START_ABSOLUTE_DAY) {\n throw new ChroneraError(\n \"CHRONERA_OUT_OF_RANGE\",\n `Date is before ROC calendar epoch (1912-01-01).`,\n );\n }\n\n const fields = gregorianFieldsFromAbsoluteDay(absoluteDay);\n if (fields.year > 9999) {\n throw new ChroneraError(\n \"CHRONERA_OUT_OF_RANGE\",\n `Date exceeds maximum supported year 9999.`,\n );\n }\n\n const rocYear = fields.year - ROC_OFFSET;\n return {\n kind: \"calendar-date\",\n calendar: \"roc\",\n era: \"roc\",\n eraYear: rocYear,\n year: rocYear,\n monthCode: formatGregorianMonthCode(fields.month),\n month: fields.month,\n day: fields.day,\n };\n },\n },\n};\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CalendarIdentity } from "../types.js";
|
|
2
|
+
export declare const ROC_OFFSET = 1911;
|
|
3
|
+
export declare const ROC_START_ABSOLUTE_DAY = -21185;
|
|
4
|
+
export declare const ROC_IDENTITY: CalendarIdentity;
|
|
5
|
+
export declare const TAIWAN_WEEKDAY_NAMES: readonly ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
|
|
6
|
+
export declare const TAIWAN_WEEKDAY_SHORT: readonly ["日", "一", "二", "三", "四", "五", "六"];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { MAX_ABSOLUTE_DAY } from "../../core/absolute-day.js";
|
|
2
|
+
export const ROC_OFFSET = 1911;
|
|
3
|
+
// 1912-01-01 (Minguo 1)
|
|
4
|
+
export const ROC_START_ABSOLUTE_DAY = -21185;
|
|
5
|
+
export const ROC_IDENTITY = {
|
|
6
|
+
id: "roc",
|
|
7
|
+
algorithm: "chronera-roc-v1",
|
|
8
|
+
deterministic: true,
|
|
9
|
+
validRange: {
|
|
10
|
+
first: ROC_START_ABSOLUTE_DAY,
|
|
11
|
+
last: MAX_ABSOLUTE_DAY,
|
|
12
|
+
},
|
|
13
|
+
validFrom: { kind: "local-date", year: 1912, month: 1, day: 1 },
|
|
14
|
+
validTo: { kind: "local-date", year: 9999, month: 12, day: 31 },
|
|
15
|
+
};
|
|
16
|
+
export const TAIWAN_WEEKDAY_NAMES = [
|
|
17
|
+
"星期日",
|
|
18
|
+
"星期一",
|
|
19
|
+
"星期二",
|
|
20
|
+
"星期三",
|
|
21
|
+
"星期四",
|
|
22
|
+
"星期五",
|
|
23
|
+
"星期六",
|
|
24
|
+
];
|
|
25
|
+
export const TAIWAN_WEEKDAY_SHORT = [
|
|
26
|
+
"日",
|
|
27
|
+
"一",
|
|
28
|
+
"二",
|
|
29
|
+
"三",
|
|
30
|
+
"四",
|
|
31
|
+
"五",
|
|
32
|
+
"六",
|
|
33
|
+
];
|
|
34
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/calendar/roc/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG9D,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC;AAE/B,wBAAwB;AACxB,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAK,CAAC;AAE7C,MAAM,CAAC,MAAM,YAAY,GAAqB;IAC5C,EAAE,EAAE,KAAK;IACT,SAAS,EAAE,iBAAiB;IAC5B,aAAa,EAAE,IAAI;IACnB,UAAU,EAAE;QACV,KAAK,EAAE,sBAAsB;QAC7B,IAAI,EAAE,gBAAgB;KACvB;IACD,SAAS,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE;IAC/D,OAAO,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;CAChE,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;CACG,CAAC;AAEX,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;CACK,CAAC","sourcesContent":["import { MAX_ABSOLUTE_DAY } from \"../../core/absolute-day.js\";\nimport type { CalendarIdentity } from \"../types.js\";\n\nexport const ROC_OFFSET = 1911;\n\n// 1912-01-01 (Minguo 1)\nexport const ROC_START_ABSOLUTE_DAY = -21185;\n\nexport const ROC_IDENTITY: CalendarIdentity = {\n id: \"roc\",\n algorithm: \"chronera-roc-v1\",\n deterministic: true,\n validRange: {\n first: ROC_START_ABSOLUTE_DAY,\n last: MAX_ABSOLUTE_DAY,\n },\n validFrom: { kind: \"local-date\", year: 1912, month: 1, day: 1 },\n validTo: { kind: \"local-date\", year: 9999, month: 12, day: 31 },\n};\n\nexport const TAIWAN_WEEKDAY_NAMES = [\n \"星期日\",\n \"星期一\",\n \"星期二\",\n \"星期三\",\n \"星期四\",\n \"星期五\",\n \"星期六\",\n] as const;\n\nexport const TAIWAN_WEEKDAY_SHORT = [\n \"日\",\n \"一\",\n \"二\",\n \"三\",\n \"四\",\n \"五\",\n \"六\",\n] as const;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/calendar/roc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export {\n ROC_OFFSET,\n ROC_START_ABSOLUTE_DAY,\n TAIWAN_WEEKDAY_NAMES,\n TAIWAN_WEEKDAY_SHORT,\n} from \"./constants.js\";\nexport { rocValidator, assertRocDate } from \"./validator.js\";\nexport { rocAdapter } from \"./adapter.js\";\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { daysInGregorianMonth, isGregorianLeapYear, parseGregorianMonthCode, } from "../../core/gregorian-math.js";
|
|
2
|
+
import { ChroneraError } from "../../errors/errors.js";
|
|
3
|
+
import { ROC_IDENTITY, ROC_OFFSET } from "./constants.js";
|
|
4
|
+
export function assertRocDate(date) {
|
|
5
|
+
if (date.calendar !== "roc") {
|
|
6
|
+
throw new ChroneraError("CHRONERA_INVALID_CALENDAR", `Expected calendar "roc", received "${date.calendar}".`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export const rocValidator = {
|
|
10
|
+
identity: ROC_IDENTITY,
|
|
11
|
+
validate(date) {
|
|
12
|
+
assertRocDate(date);
|
|
13
|
+
const issues = [];
|
|
14
|
+
const monthNum = parseGregorianMonthCode(date.monthCode);
|
|
15
|
+
if (monthNum === null) {
|
|
16
|
+
issues.push({
|
|
17
|
+
code: "CHRONERA_INVALID_DATE",
|
|
18
|
+
message: `Invalid monthCode: "${date.monthCode}". Expected M01-M12.`,
|
|
19
|
+
path: ["monthCode"],
|
|
20
|
+
});
|
|
21
|
+
return issues;
|
|
22
|
+
}
|
|
23
|
+
const gregorianYear = date.year + ROC_OFFSET;
|
|
24
|
+
if (date.year < 1 || gregorianYear > 9999) {
|
|
25
|
+
issues.push({
|
|
26
|
+
code: "CHRONERA_OUT_OF_RANGE",
|
|
27
|
+
message: `ROC calendar supports years >= 1 (Gregorian 1912-9999). Received year: ${date.year}.`,
|
|
28
|
+
path: ["year"],
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const maxDays = daysInGregorianMonth(gregorianYear, monthNum);
|
|
32
|
+
if (date.day < 1 || date.day > maxDays) {
|
|
33
|
+
issues.push({
|
|
34
|
+
code: "CHRONERA_INVALID_DATE",
|
|
35
|
+
message: `Invalid day ${date.day} for ROC year ${date.year} month ${monthNum}. Expected 1..${maxDays}.`,
|
|
36
|
+
path: ["day"],
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return issues;
|
|
40
|
+
},
|
|
41
|
+
daysInMonth(year, monthCode) {
|
|
42
|
+
const month = parseGregorianMonthCode(monthCode);
|
|
43
|
+
if (month === null) {
|
|
44
|
+
throw new ChroneraError("CHRONERA_INVALID_DATE", `Invalid monthCode: "${monthCode}". Expected M01-M12.`);
|
|
45
|
+
}
|
|
46
|
+
return daysInGregorianMonth(year + ROC_OFFSET, month);
|
|
47
|
+
},
|
|
48
|
+
isLeapYear(year) {
|
|
49
|
+
return isGregorianLeapYear(year + ROC_OFFSET);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../src/calendar/roc/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAS1D,MAAM,UAAU,aAAa,CAAC,IAAkB;IAC9C,IAAI,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;QAC5B,MAAM,IAAI,aAAa,CACrB,2BAA2B,EAC3B,sCAAsC,IAAI,CAAC,QAAQ,IAAI,CACxD,CAAC;IACJ,CAAC;AACH,CAAC;AAED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AY,EAAE,SAAoB;QAC5C,MAAM,KAAK,GAAG,uBAAuB,CAAC,SAAS,CAAC,CAAC;QACjD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,MAAM,IAAI,aAAa,CACrB,uBAAuB,EACvB,uBAAuB,SAAS,sBAAsB,CACvD,CAAC;QACJ,CAAC;QACD,OAAO,oBAAoB,CAAC,IAAI,GAAG,UAAU,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,OAAO,mBAAmB,CAAC,IAAI,GAAG,UAAU,CAAC,CAAC;IAChD,CAAC;CACF,CAAC","sourcesContent":["import {\n daysInGregorianMonth,\n isGregorianLeapYear,\n parseGregorianMonthCode,\n} from \"../../core/gregorian-math.js\";\nimport { ChroneraError } from \"../../errors/errors.js\";\nimport { ROC_IDENTITY, ROC_OFFSET } from \"./constants.js\";\n\nimport type { CalendarValidator } from \"../types.js\";\nimport type {\n CalendarDate,\n ChroneraIssue,\n MonthCode,\n} from \"../../public-types.js\";\n\nexport function assertRocDate(date: CalendarDate): void {\n if (date.calendar !== \"roc\") {\n throw new ChroneraError(\n \"CHRONERA_INVALID_CALENDAR\",\n `Expected calendar \"roc\", received \"${date.calendar}\".`,\n );\n }\n}\n\nexport const rocValidator: CalendarValidator = {\n identity: ROC_IDENTITY,\n\n validate(date: CalendarDate): readonly ChroneraIssue[] {\n assertRocDate(date);\n const issues: ChroneraIssue[] = [];\n\n const monthNum = parseGregorianMonthCode(date.monthCode);\n if (monthNum === null) {\n issues.push({\n code: \"CHRONERA_INVALID_DATE\",\n message: `Invalid monthCode: \"${date.monthCode}\". Expected M01-M12.`,\n path: [\"monthCode\"],\n });\n return issues;\n }\n\n const gregorianYear = date.year + ROC_OFFSET;\n if (date.year < 1 || gregorianYear > 9999) {\n issues.push({\n code: \"CHRONERA_OUT_OF_RANGE\",\n message: `ROC calendar supports years >= 1 (Gregorian 1912-9999). Received year: ${date.year}.`,\n path: [\"year\"],\n });\n }\n\n const maxDays = daysInGregorianMonth(gregorianYear, monthNum);\n if (date.day < 1 || date.day > maxDays) {\n issues.push({\n code: \"CHRONERA_INVALID_DATE\",\n message: `Invalid day ${date.day} for ROC year ${date.year} month ${monthNum}. Expected 1..${maxDays}.`,\n path: [\"day\"],\n });\n }\n\n return issues;\n },\n\n daysInMonth(year: number, monthCode: MonthCode): number {\n const month = parseGregorianMonthCode(monthCode);\n if (month === null) {\n throw new ChroneraError(\n \"CHRONERA_INVALID_DATE\",\n `Invalid monthCode: \"${monthCode}\". Expected M01-M12.`,\n );\n }\n return daysInGregorianMonth(year + ROC_OFFSET, month);\n },\n\n isLeapYear(year: number): boolean {\n return isGregorianLeapYear(year + ROC_OFFSET);\n },\n};\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CalendarDate, CalendarId, ChroneraIssue, Duration, LocalDate, MonthCode } from "../public-types.js";
|
|
2
|
+
export interface CalendarIdentity {
|
|
3
|
+
readonly id: CalendarId;
|
|
4
|
+
readonly algorithm: string;
|
|
5
|
+
readonly deterministic: boolean;
|
|
6
|
+
readonly dataVersion?: string;
|
|
7
|
+
readonly validRange: {
|
|
8
|
+
readonly first: number;
|
|
9
|
+
readonly last: number;
|
|
10
|
+
};
|
|
11
|
+
readonly validFrom?: LocalDate;
|
|
12
|
+
readonly validTo?: LocalDate;
|
|
13
|
+
}
|
|
14
|
+
export interface CalendarConverter {
|
|
15
|
+
readonly identity: CalendarIdentity;
|
|
16
|
+
toAbsoluteDay(date: CalendarDate): number;
|
|
17
|
+
fromAbsoluteDay(day: number): CalendarDate;
|
|
18
|
+
}
|
|
19
|
+
export interface CalendarValidator {
|
|
20
|
+
readonly identity: CalendarIdentity;
|
|
21
|
+
validate(date: CalendarDate): readonly ChroneraIssue[];
|
|
22
|
+
daysInMonth(year: number, monthCode: MonthCode): number;
|
|
23
|
+
isLeapYear(year: number): boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface CalendarArithmetic {
|
|
26
|
+
readonly identity: CalendarIdentity;
|
|
27
|
+
add(date: CalendarDate, duration: Duration, overflow: "constrain" | "reject"): CalendarDate;
|
|
28
|
+
}
|
|
29
|
+
export interface CalendarAdapter {
|
|
30
|
+
readonly identity: CalendarIdentity;
|
|
31
|
+
readonly converter?: CalendarConverter;
|
|
32
|
+
readonly validator: CalendarValidator;
|
|
33
|
+
readonly arithmetic?: CalendarArithmetic;
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/calendar/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n CalendarDate,\n CalendarId,\n ChroneraIssue,\n Duration,\n LocalDate,\n MonthCode,\n} from \"../public-types.js\";\n\nexport interface CalendarIdentity {\n readonly id: CalendarId;\n readonly algorithm: string;\n readonly deterministic: boolean;\n readonly dataVersion?: string;\n readonly validRange: {\n readonly first: number;\n readonly last: number;\n };\n readonly validFrom?: LocalDate;\n readonly validTo?: LocalDate;\n}\n\nexport interface CalendarConverter {\n readonly identity: CalendarIdentity;\n toAbsoluteDay(date: CalendarDate): number;\n fromAbsoluteDay(day: number): CalendarDate;\n}\n\nexport interface CalendarValidator {\n readonly identity: CalendarIdentity;\n validate(date: CalendarDate): readonly ChroneraIssue[];\n daysInMonth(year: number, monthCode: MonthCode): number;\n isLeapYear(year: number): boolean;\n}\n\nexport interface CalendarArithmetic {\n readonly identity: CalendarIdentity;\n add(\n date: CalendarDate,\n duration: Duration,\n overflow: \"constrain\" | \"reject\",\n ): CalendarDate;\n}\n\nexport interface CalendarAdapter {\n readonly identity: CalendarIdentity;\n readonly converter?: CalendarConverter;\n readonly validator: CalendarValidator;\n readonly arithmetic?: CalendarArithmetic;\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const MIN_ABSOLUTE_DAY = -719162;
|
|
2
|
+
export declare const MAX_ABSOLUTE_DAY = 2932896;
|
|
3
|
+
export declare function absoluteDayFromGregorianFields(year: number, month: number, day: number): number;
|
|
4
|
+
export declare function gregorianFieldsFromAbsoluteDay(absoluteDay: number): {
|
|
5
|
+
year: number;
|
|
6
|
+
month: number;
|
|
7
|
+
day: number;
|
|
8
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ChroneraError } from "../errors/errors.js";
|
|
2
|
+
export const MIN_ABSOLUTE_DAY = -719162;
|
|
3
|
+
export const MAX_ABSOLUTE_DAY = 2932896;
|
|
4
|
+
const DAY_OFFSET = 719468;
|
|
5
|
+
export function absoluteDayFromGregorianFields(year, month, day) {
|
|
6
|
+
const y = month <= 2 ? year - 1 : year;
|
|
7
|
+
const era = Math.floor(y >= 0 ? y / 400 : (y - 399) / 400);
|
|
8
|
+
const yoe = y - era * 400;
|
|
9
|
+
const doy = Math.floor((153 * (month > 2 ? month - 3 : month + 9) + 2) / 5) + day - 1;
|
|
10
|
+
const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;
|
|
11
|
+
const absoluteDay = era * 146097 + doe - DAY_OFFSET;
|
|
12
|
+
if (absoluteDay < MIN_ABSOLUTE_DAY || absoluteDay > MAX_ABSOLUTE_DAY) {
|
|
13
|
+
throw new ChroneraError("CHRONERA_OUT_OF_RANGE", `Date ${year}-${String(month).padStart(2, "0")}-${String(day).padStart(2, "0")} is outside supported absolute day range [${MIN_ABSOLUTE_DAY}, ${MAX_ABSOLUTE_DAY}].`);
|
|
14
|
+
}
|
|
15
|
+
return absoluteDay;
|
|
16
|
+
}
|
|
17
|
+
export function gregorianFieldsFromAbsoluteDay(absoluteDay) {
|
|
18
|
+
if (!Number.isSafeInteger(absoluteDay) ||
|
|
19
|
+
absoluteDay < MIN_ABSOLUTE_DAY ||
|
|
20
|
+
absoluteDay > MAX_ABSOLUTE_DAY) {
|
|
21
|
+
throw new ChroneraError("CHRONERA_OUT_OF_RANGE", `Absolute day ${absoluteDay} is outside supported range [${MIN_ABSOLUTE_DAY}, ${MAX_ABSOLUTE_DAY}].`);
|
|
22
|
+
}
|
|
23
|
+
const z = absoluteDay + DAY_OFFSET;
|
|
24
|
+
const era = Math.floor(z >= 0 ? z / 146097 : (z - 146096) / 146097);
|
|
25
|
+
const doe = z - era * 146097;
|
|
26
|
+
const yoe = Math.floor((doe -
|
|
27
|
+
Math.floor(doe / 1460) +
|
|
28
|
+
Math.floor(doe / 36524) -
|
|
29
|
+
Math.floor(doe / 146096)) /
|
|
30
|
+
365);
|
|
31
|
+
const y = yoe + era * 400;
|
|
32
|
+
const doy = doe - (365 * yoe + Math.floor(yoe / 4) - Math.floor(yoe / 100));
|
|
33
|
+
const mp = Math.floor((5 * doy + 2) / 153);
|
|
34
|
+
const day = doy - Math.floor((153 * mp + 2) / 5) + 1;
|
|
35
|
+
const month = mp < 10 ? mp + 3 : mp - 9;
|
|
36
|
+
const year = month <= 2 ? y + 1 : y;
|
|
37
|
+
return { year, month, day };
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=absolute-day.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"absolute-day.js","sourceRoot":"","sources":["../../src/core/absolute-day.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAM,CAAC;AACxC,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAExC,MAAM,UAAU,GAAG,MAAM,CAAC;AAE1B,MAAM,UAAU,8BAA8B,CAC5C,IAAY,EACZ,KAAa,EACb,GAAW;IAEX,MAAM,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAA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AAC,CAAC;IAEpC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["import { ChroneraError } from \"../errors/errors.js\";\n\nexport const MIN_ABSOLUTE_DAY = -719162;\nexport const MAX_ABSOLUTE_DAY = 2932896;\n\nconst DAY_OFFSET = 719468;\n\nexport function absoluteDayFromGregorianFields(\n year: number,\n month: number,\n day: number,\n): number {\n const y = month <= 2 ? year - 1 : year;\n const era = Math.floor(y >= 0 ? y / 400 : (y - 399) / 400);\n const yoe = y - era * 400;\n const doy =\n Math.floor((153 * (month > 2 ? month - 3 : month + 9) + 2) / 5) + day - 1;\n const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;\n const absoluteDay = era * 146097 + doe - DAY_OFFSET;\n\n if (absoluteDay < MIN_ABSOLUTE_DAY || absoluteDay > MAX_ABSOLUTE_DAY) {\n throw new ChroneraError(\n \"CHRONERA_OUT_OF_RANGE\",\n `Date ${year}-${String(month).padStart(2, \"0\")}-${String(day).padStart(2, \"0\")} is outside supported absolute day range [${MIN_ABSOLUTE_DAY}, ${MAX_ABSOLUTE_DAY}].`,\n );\n }\n\n return absoluteDay;\n}\n\nexport function gregorianFieldsFromAbsoluteDay(absoluteDay: number): {\n year: number;\n month: number;\n day: number;\n} {\n if (\n !Number.isSafeInteger(absoluteDay) ||\n absoluteDay < MIN_ABSOLUTE_DAY ||\n absoluteDay > MAX_ABSOLUTE_DAY\n ) {\n throw new ChroneraError(\n \"CHRONERA_OUT_OF_RANGE\",\n `Absolute day ${absoluteDay} is outside supported range [${MIN_ABSOLUTE_DAY}, ${MAX_ABSOLUTE_DAY}].`,\n );\n }\n\n const z = absoluteDay + DAY_OFFSET;\n const era = Math.floor(z >= 0 ? z / 146097 : (z - 146096) / 146097);\n const doe = z - era * 146097;\n const yoe = Math.floor(\n (doe -\n Math.floor(doe / 1460) +\n Math.floor(doe / 36524) -\n Math.floor(doe / 146096)) /\n 365,\n );\n const y = yoe + era * 400;\n const doy = doe - (365 * yoe + Math.floor(yoe / 4) - Math.floor(yoe / 100));\n const mp = Math.floor((5 * doy + 2) / 153);\n const day = doy - Math.floor((153 * mp + 2) / 5) + 1;\n const month = mp < 10 ? mp + 3 : mp - 9;\n const year = month <= 2 ? y + 1 : y;\n\n return { year, month, day };\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CalendarDate, CalendarId, EraId, MonthCode } from "../public-types.js";
|
|
2
|
+
export interface CalendarDateInit {
|
|
3
|
+
calendar: CalendarId;
|
|
4
|
+
year: number;
|
|
5
|
+
monthCode: MonthCode;
|
|
6
|
+
day: number;
|
|
7
|
+
era?: EraId;
|
|
8
|
+
eraYear?: number;
|
|
9
|
+
month?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function calendarDate(init: CalendarDateInit): CalendarDate;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ChroneraError } from "../errors/errors.js";
|
|
2
|
+
import { requireInteger } from "./integer.js";
|
|
3
|
+
export function calendarDate(init) {
|
|
4
|
+
if (!init || typeof init !== "object") {
|
|
5
|
+
throw new ChroneraError("CHRONERA_INVALID_DATE", "Expected calendar date fields object.");
|
|
6
|
+
}
|
|
7
|
+
if (!init.calendar || typeof init.calendar !== "string") {
|
|
8
|
+
throw new ChroneraError("CHRONERA_INVALID_CALENDAR", `Invalid calendar identifier: ${String(init.calendar)}.`);
|
|
9
|
+
}
|
|
10
|
+
requireInteger("year", init.year);
|
|
11
|
+
requireInteger("day", init.day);
|
|
12
|
+
if (typeof init.monthCode !== "string" || !init.monthCode.startsWith("M")) {
|
|
13
|
+
throw new ChroneraError("CHRONERA_INVALID_DATE", `Invalid month code: ${String(init.monthCode)}. Must start with 'M'.`);
|
|
14
|
+
}
|
|
15
|
+
if (init.month !== undefined) {
|
|
16
|
+
requireInteger("month", init.month);
|
|
17
|
+
}
|
|
18
|
+
if (init.eraYear !== undefined) {
|
|
19
|
+
requireInteger("eraYear", init.eraYear);
|
|
20
|
+
}
|
|
21
|
+
let month = init.month;
|
|
22
|
+
if (month === undefined && /^M\d{2}$/.test(init.monthCode)) {
|
|
23
|
+
month = Number.parseInt(init.monthCode.slice(1), 10);
|
|
24
|
+
}
|
|
25
|
+
const result = {
|
|
26
|
+
kind: "calendar-date",
|
|
27
|
+
calendar: init.calendar,
|
|
28
|
+
year: init.year,
|
|
29
|
+
monthCode: init.monthCode,
|
|
30
|
+
day: init.day,
|
|
31
|
+
...(init.era !== undefined ? { era: init.era } : {}),
|
|
32
|
+
...(init.eraYear !== undefined ? { eraYear: init.eraYear } : {}),
|
|
33
|
+
...(month !== undefined ? { month } : {}),
|
|
34
|
+
};
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=calendar-date.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-date.js","sourceRoot":"","sources":["../../src/core/calendar-date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAmB9C,MAAM,UAAU,YAAY,CAAC,IAAsB;IACjD,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtC,MAAM,IAAI,aAAa,CACrB,uBAAuB,EACvB,uCAAuC,CACxC,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACxD,MAAM,IAAI,aAAa,CACrB,2BAA2B,EAC3B,gCAAgC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CACzD,CAAC;IACJ,CAAC;IAED,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IA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,CAAC;QAChE,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1C,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { ChroneraError } from \"../errors/errors.js\";\nimport { requireInteger } from \"./integer.js\";\n\nimport type {\n CalendarDate,\n CalendarId,\n EraId,\n MonthCode,\n} from \"../public-types.js\";\n\nexport interface CalendarDateInit {\n calendar: CalendarId;\n year: number;\n monthCode: MonthCode;\n day: number;\n era?: EraId;\n eraYear?: number;\n month?: number;\n}\n\nexport function calendarDate(init: CalendarDateInit): CalendarDate {\n if (!init || typeof init !== \"object\") {\n throw new ChroneraError(\n \"CHRONERA_INVALID_DATE\",\n \"Expected calendar date fields object.\",\n );\n }\n\n if (!init.calendar || typeof init.calendar !== \"string\") {\n throw new ChroneraError(\n \"CHRONERA_INVALID_CALENDAR\",\n `Invalid calendar identifier: ${String(init.calendar)}.`,\n );\n }\n\n requireInteger(\"year\", init.year);\n requireInteger(\"day\", init.day);\n\n if (typeof init.monthCode !== \"string\" || !init.monthCode.startsWith(\"M\")) {\n throw new ChroneraError(\n \"CHRONERA_INVALID_DATE\",\n `Invalid month code: ${String(init.monthCode)}. Must start with 'M'.`,\n );\n }\n\n if (init.month !== undefined) {\n requireInteger(\"month\", init.month);\n }\n\n if (init.eraYear !== undefined) {\n requireInteger(\"eraYear\", init.eraYear);\n }\n\n let month = init.month;\n if (month === undefined && /^M\\d{2}$/.test(init.monthCode)) {\n month = Number.parseInt(init.monthCode.slice(1), 10);\n }\n\n const result: CalendarDate = {\n kind: \"calendar-date\",\n calendar: init.calendar,\n year: init.year,\n monthCode: init.monthCode,\n day: init.day,\n ...(init.era !== undefined ? { era: init.era } : {}),\n ...(init.eraYear !== undefined ? { eraYear: init.eraYear } : {}),\n ...(month !== undefined ? { month } : {}),\n };\n\n return result;\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface DayOfYearFields {
|
|
2
|
+
readonly year: number;
|
|
3
|
+
readonly dayOfYear: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Calculates the ordinal day of year (1..366) from an absolute day.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getDayOfYearFromAbsoluteDay(absoluteDay: number): DayOfYearFields;
|
|
9
|
+
/**
|
|
10
|
+
* Calculates the ordinal day of year (1..366) from Gregorian year, month, and day.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getDayOfYearFromGregorianFields(year: number, month: number, day: number): number;
|
|
13
|
+
/**
|
|
14
|
+
* Formats an ISO 8601 ordinal date string: YYYY-DDD (e.g. 2026-245).
|
|
15
|
+
*/
|
|
16
|
+
export declare function formatOrdinalDate(year: number, dayOfYear: number): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { absoluteDayFromGregorianFields, gregorianFieldsFromAbsoluteDay, } from "./absolute-day.js";
|
|
2
|
+
/**
|
|
3
|
+
* Calculates the ordinal day of year (1..366) from an absolute day.
|
|
4
|
+
*/
|
|
5
|
+
export function getDayOfYearFromAbsoluteDay(absoluteDay) {
|
|
6
|
+
const fields = gregorianFieldsFromAbsoluteDay(absoluteDay);
|
|
7
|
+
const startOfYearAbsDay = absoluteDayFromGregorianFields(fields.year, 1, 1);
|
|
8
|
+
const dayOfYear = absoluteDay - startOfYearAbsDay + 1;
|
|
9
|
+
return {
|
|
10
|
+
year: fields.year,
|
|
11
|
+
dayOfYear,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Calculates the ordinal day of year (1..366) from Gregorian year, month, and day.
|
|
16
|
+
*/
|
|
17
|
+
export function getDayOfYearFromGregorianFields(year, month, day) {
|
|
18
|
+
const targetAbsDay = absoluteDayFromGregorianFields(year, month, day);
|
|
19
|
+
const startOfYearAbsDay = absoluteDayFromGregorianFields(year, 1, 1);
|
|
20
|
+
return targetAbsDay - startOfYearAbsDay + 1;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Formats an ISO 8601 ordinal date string: YYYY-DDD (e.g. 2026-245).
|
|
24
|
+
*/
|
|
25
|
+
export function formatOrdinalDate(year, dayOfYear) {
|
|
26
|
+
const paddedYear = String(year).padStart(4, "0");
|
|
27
|
+
const paddedDoy = String(dayOfYear).padStart(3, "0");
|
|
28
|
+
return `${paddedYear}-${paddedDoy}`;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=day-of-year.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"day-of-year.js","sourceRoot":"","sources":["../../src/core/day-of-year.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,GAC/B,MAAM,mBAAmB,CAAC;AAO3B;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,WAAmB;IAEnB,MAAM,MAAM,GAAG,8BAA8B,CAAC,WAAW,CAAC,CAAC;IAC3D,MAAM,iBAAiB,GAAG,8BAA8B,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5E,MAAM,SAAS,GAAG,WAAW,GAAG,iBAAiB,GAAG,CAAC,CAAC;IACtD,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,SAAS;KACV,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,+BAA+B,CAC7C,IAAY,EACZ,KAAa,EACb,GAAW;IAEX,MAAM,YAAY,GAAG,8BAA8B,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IACtE,MAAM,iBAAiB,GAAG,8BAA8B,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACrE,OAAO,YAAY,GAAG,iBAAiB,GAAG,CAAC,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,SAAiB;IAC/D,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACjD,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACrD,OAAO,GAAG,UAAU,IAAI,SAAS,EAAE,CAAC;AACtC,CAAC","sourcesContent":["import {\n absoluteDayFromGregorianFields,\n gregorianFieldsFromAbsoluteDay,\n} from \"./absolute-day.js\";\n\nexport interface DayOfYearFields {\n readonly year: number;\n readonly dayOfYear: number;\n}\n\n/**\n * Calculates the ordinal day of year (1..366) from an absolute day.\n */\nexport function getDayOfYearFromAbsoluteDay(\n absoluteDay: number,\n): DayOfYearFields {\n const fields = gregorianFieldsFromAbsoluteDay(absoluteDay);\n const startOfYearAbsDay = absoluteDayFromGregorianFields(fields.year, 1, 1);\n const dayOfYear = absoluteDay - startOfYearAbsDay + 1;\n return {\n year: fields.year,\n dayOfYear,\n };\n}\n\n/**\n * Calculates the ordinal day of year (1..366) from Gregorian year, month, and day.\n */\nexport function getDayOfYearFromGregorianFields(\n year: number,\n month: number,\n day: number,\n): number {\n const targetAbsDay = absoluteDayFromGregorianFields(year, month, day);\n const startOfYearAbsDay = absoluteDayFromGregorianFields(year, 1, 1);\n return targetAbsDay - startOfYearAbsDay + 1;\n}\n\n/**\n * Formats an ISO 8601 ordinal date string: YYYY-DDD (e.g. 2026-245).\n */\nexport function formatOrdinalDate(year: number, dayOfYear: number): string {\n const paddedYear = String(year).padStart(4, \"0\");\n const paddedDoy = String(dayOfYear).padStart(3, \"0\");\n return `${paddedYear}-${paddedDoy}`;\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ChroneraError } from "../errors/errors.js";
|
|
2
|
+
import { requireInteger } from "./integer.js";
|
|
3
|
+
export function duration(init) {
|
|
4
|
+
let hasPositive = false;
|
|
5
|
+
let hasNegative = false;
|
|
6
|
+
const fields = [
|
|
7
|
+
"years",
|
|
8
|
+
"months",
|
|
9
|
+
"weeks",
|
|
10
|
+
"days",
|
|
11
|
+
"hours",
|
|
12
|
+
"minutes",
|
|
13
|
+
"seconds",
|
|
14
|
+
"milliseconds",
|
|
15
|
+
];
|
|
16
|
+
for (const field of fields) {
|
|
17
|
+
const val = init[field];
|
|
18
|
+
if (val !== undefined) {
|
|
19
|
+
requireInteger(field, val);
|
|
20
|
+
if (val > 0)
|
|
21
|
+
hasPositive = true;
|
|
22
|
+
if (val < 0)
|
|
23
|
+
hasNegative = true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (hasPositive && hasNegative) {
|
|
27
|
+
throw new ChroneraError("CHRONERA_INCOMPATIBLE_OPTION", "Mixed-sign duration fields are not supported.");
|
|
28
|
+
}
|
|
29
|
+
return { ...init };
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=duration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.js","sourceRoot":"","sources":["../../src/core/duration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAI9C,MAAM,UAAU,QAAQ,CAAC,IAAc;IACrC,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,WAAW,GAAG,KAAK,CAAC;IAExB,MAAM,MAAM,GAAuB;QACjC,OAAO;QACP,QAAQ;QACR,OAAO;QACP,MAAM;QACN,OAAO;QACP,SAAS;QACT,SAAS;QACT,cAAc;KACf,CAAC;IAEF,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC3B,IAAI,GAAG,GAAG,CAAC;gBAAE,WAAW,GAAG,IAAI,CAAC;YAChC,IAAI,GAAG,GAAG,CAAC;gBAAE,WAAW,GAAG,IAAI,CAAC;QAClC,CAAC;IACH,CAAC;IAED,IAAI,WAAW,IAAI,WAAW,EAAE,CAAC;QAC/B,MAAM,IAAI,aAAa,CACrB,8BAA8B,EAC9B,+CAA+C,CAChD,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;AACrB,CAAC","sourcesContent":["import { ChroneraError } from \"../errors/errors.js\";\nimport { requireInteger } from \"./integer.js\";\n\nimport type { Duration } from \"../public-types.js\";\n\nexport function duration(init: Duration): Duration {\n let hasPositive = false;\n let hasNegative = false;\n\n const fields: (keyof Duration)[] = [\n \"years\",\n \"months\",\n \"weeks\",\n \"days\",\n \"hours\",\n \"minutes\",\n \"seconds\",\n \"milliseconds\",\n ];\n\n for (const field of fields) {\n const val = init[field];\n if (val !== undefined) {\n requireInteger(field, val);\n if (val > 0) hasPositive = true;\n if (val < 0) hasNegative = true;\n }\n }\n\n if (hasPositive && hasNegative) {\n throw new ChroneraError(\n \"CHRONERA_INCOMPATIBLE_OPTION\",\n \"Mixed-sign duration fields are not supported.\",\n );\n }\n\n return { ...init };\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type QuarterNumber = 1 | 2 | 3 | 4;
|
|
2
|
+
export interface FiscalOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Starting month of the fiscal year (1..12). Defaults to 1 (calendar year).
|
|
5
|
+
* Common corporate/governmental standards:
|
|
6
|
+
* - 1: Calendar year (US corporate default, China, Germany)
|
|
7
|
+
* - 4: April 1 (United Kingdom, Japan, India, Canada)
|
|
8
|
+
* - 7: July 1 (Australia, New Zealand)
|
|
9
|
+
* - 10: October 1 (United States Federal Government)
|
|
10
|
+
*/
|
|
11
|
+
readonly startMonth?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the fiscal year is labeled by the year it ends (standard in US/UK accounting)
|
|
14
|
+
* or the year it starts. Defaults to "endYear".
|
|
15
|
+
*/
|
|
16
|
+
readonly label?: "endYear" | "startYear";
|
|
17
|
+
}
|
|
18
|
+
export interface FiscalFields {
|
|
19
|
+
readonly fiscalYear: number;
|
|
20
|
+
readonly fiscalQuarter: QuarterNumber;
|
|
21
|
+
readonly calendarQuarter: QuarterNumber;
|
|
22
|
+
readonly quarterMonth: 1 | 2 | 3;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Calculates calendar quarter (1..4) from a 1-based month (1..12).
|
|
26
|
+
*/
|
|
27
|
+
export declare function getCalendarQuarter(month: number): QuarterNumber;
|
|
28
|
+
/**
|
|
29
|
+
* Calculates fiscal fields for a given Gregorian year and month.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getFiscalFields(year: number, month: number, options?: FiscalOptions): FiscalFields;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates calendar quarter (1..4) from a 1-based month (1..12).
|
|
3
|
+
*/
|
|
4
|
+
export function getCalendarQuarter(month) {
|
|
5
|
+
if (month < 1 || month > 12) {
|
|
6
|
+
throw new RangeError(`Invalid month: ${month}. Expected 1..12.`);
|
|
7
|
+
}
|
|
8
|
+
return (Math.floor((month - 1) / 3) + 1);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Calculates fiscal fields for a given Gregorian year and month.
|
|
12
|
+
*/
|
|
13
|
+
export function getFiscalFields(year, month, options = {}) {
|
|
14
|
+
if (month < 1 || month > 12) {
|
|
15
|
+
throw new RangeError(`Invalid month: ${month}. Expected 1..12.`);
|
|
16
|
+
}
|
|
17
|
+
const startMonth = options.startMonth ?? 1;
|
|
18
|
+
if (startMonth < 1 || startMonth > 12) {
|
|
19
|
+
throw new RangeError(`Invalid fiscal startMonth: ${startMonth}. Expected 1..12.`);
|
|
20
|
+
}
|
|
21
|
+
const label = options.label ?? "endYear";
|
|
22
|
+
const calendarQuarter = getCalendarQuarter(month);
|
|
23
|
+
// Month index relative to fiscal year start (0..11)
|
|
24
|
+
const relativeMonth = (month - startMonth + 12) % 12;
|
|
25
|
+
const fiscalQuarter = (Math.floor(relativeMonth / 3) + 1);
|
|
26
|
+
const quarterMonth = ((relativeMonth % 3) + 1);
|
|
27
|
+
let fiscalYear = year;
|
|
28
|
+
if (startMonth !== 1) {
|
|
29
|
+
if (label === "endYear") {
|
|
30
|
+
// If month is on or after startMonth, it belongs to the fiscal year ending next calendar year
|
|
31
|
+
fiscalYear = month >= startMonth ? year + 1 : year;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
// startYear: if month is before startMonth, it belongs to the fiscal year started in previous calendar year
|
|
35
|
+
fiscalYear = month < startMonth ? year - 1 : year;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
fiscalYear,
|
|
40
|
+
fiscalQuarter,
|
|
41
|
+
calendarQuarter,
|
|
42
|
+
quarterMonth,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=fiscal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fiscal.js","sourceRoot":"","sources":["../../src/core/fiscal.ts"],"names":[],"mappings":"AA2BA;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE,EAAE,CAAC;QAC5B,MAAM,IAAI,UAAU,CAAC,kBAAkB,KAAK,mBAAmB,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAkB,CAAC;AAC5D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAY,EACZ,KAAa,EACb,UAAyB,EAAE;IAE3B,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE,EAAE,CAAC;QAC5B,MAAM,IA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1..12). Defaults to 1 (calendar year).\n * Common corporate/governmental standards:\n * - 1: Calendar year (US corporate default, China, Germany)\n * - 4: April 1 (United Kingdom, Japan, India, Canada)\n * - 7: July 1 (Australia, New Zealand)\n * - 10: October 1 (United States Federal Government)\n */\n readonly startMonth?: number;\n\n /**\n * Whether the fiscal year is labeled by the year it ends (standard in US/UK accounting)\n * or the year it starts. Defaults to \"endYear\".\n */\n readonly label?: \"endYear\" | \"startYear\";\n}\n\nexport interface FiscalFields {\n readonly fiscalYear: number;\n readonly fiscalQuarter: QuarterNumber;\n readonly calendarQuarter: QuarterNumber;\n readonly quarterMonth: 1 | 2 | 3; // 1st, 2nd, or 3rd month of the quarter\n}\n\n/**\n * Calculates calendar quarter (1..4) from a 1-based month (1..12).\n */\nexport function getCalendarQuarter(month: number): QuarterNumber {\n if (month < 1 || month > 12) {\n throw new RangeError(`Invalid month: ${month}. Expected 1..12.`);\n }\n return (Math.floor((month - 1) / 3) + 1) as QuarterNumber;\n}\n\n/**\n * Calculates fiscal fields for a given Gregorian year and month.\n */\nexport function getFiscalFields(\n year: number,\n month: number,\n options: FiscalOptions = {},\n): FiscalFields {\n if (month < 1 || month > 12) {\n throw new RangeError(`Invalid month: ${month}. Expected 1..12.`);\n }\n\n const startMonth = options.startMonth ?? 1;\n if (startMonth < 1 || startMonth > 12) {\n throw new RangeError(\n `Invalid fiscal startMonth: ${startMonth}. Expected 1..12.`,\n );\n }\n\n const label = options.label ?? \"endYear\";\n const calendarQuarter = getCalendarQuarter(month);\n\n // Month index relative to fiscal year start (0..11)\n const relativeMonth = (month - startMonth + 12) % 12;\n const fiscalQuarter = (Math.floor(relativeMonth / 3) + 1) as QuarterNumber;\n const quarterMonth = ((relativeMonth % 3) + 1) as 1 | 2 | 3;\n\n let fiscalYear = year;\n if (startMonth !== 1) {\n if (label === \"endYear\") {\n // If month is on or after startMonth, it belongs to the fiscal year ending next calendar year\n fiscalYear = month >= startMonth ? year + 1 : year;\n } else {\n // startYear: if month is before startMonth, it belongs to the fiscal year started in previous calendar year\n fiscalYear = month < startMonth ? year - 1 : year;\n }\n }\n\n return {\n fiscalYear,\n fiscalQuarter,\n calendarQuarter,\n quarterMonth,\n };\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function isGregorianLeapYear(year: number): boolean;
|
|
2
|
+
export declare function daysInGregorianMonth(year: number, month: number): number;
|
|
3
|
+
export declare function parseGregorianMonthCode(monthCode: string): number;
|
|
4
|
+
export declare function formatGregorianMonthCode(month: number): `M${string}`;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ChroneraError } from "../errors/errors.js";
|
|
2
|
+
export function isGregorianLeapYear(year) {
|
|
3
|
+
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
|
4
|
+
}
|
|
5
|
+
const COMMON_YEAR_MONTH_DAYS = [
|
|
6
|
+
0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
|
|
7
|
+
];
|
|
8
|
+
export function daysInGregorianMonth(year, month) {
|
|
9
|
+
if (month < 1 || month > 12) {
|
|
10
|
+
throw new ChroneraError("CHRONERA_INVALID_DATE", `Gregorian month must be between 1 and 12; received ${month}.`);
|
|
11
|
+
}
|
|
12
|
+
if (month === 2 && isGregorianLeapYear(year)) {
|
|
13
|
+
return 29;
|
|
14
|
+
}
|
|
15
|
+
const days = COMMON_YEAR_MONTH_DAYS[month];
|
|
16
|
+
if (days === undefined) {
|
|
17
|
+
throw new ChroneraError("CHRONERA_INVALID_DATE", `Invalid Gregorian month ${month}.`);
|
|
18
|
+
}
|
|
19
|
+
return days;
|
|
20
|
+
}
|
|
21
|
+
export function parseGregorianMonthCode(monthCode) {
|
|
22
|
+
if (!/^M(0[1-9]|1[0-2])$/.test(monthCode)) {
|
|
23
|
+
throw new ChroneraError("CHRONERA_INVALID_DATE", `Invalid Gregorian month code: "${monthCode}". Expected format M01 through M12.`);
|
|
24
|
+
}
|
|
25
|
+
return Number.parseInt(monthCode.slice(1), 10);
|
|
26
|
+
}
|
|
27
|
+
export function formatGregorianMonthCode(month) {
|
|
28
|
+
return `M${String(month).padStart(2, "0")}`;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=gregorian-math.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gregorian-math.js","sourceRoot":"","sources":["../../src/core/gregorian-math.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,OAAO,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,GAAG,KAAK,CAAC,CAAC,IAAI,IAAI,GAAG,GAAG,KAAK,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,sBAAsB,GAAG;IAC7B,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;CACzC,CAAC;AAEX,MAAM,UAAU,oBAAoB,CAAC,IAAY,EAAE,KAAa;IAC9D,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE,EAAE,CAAC;QAC5B,MAAM,IAAI,aAAa,CACrB,uBAAuB,EACvB,sDAAsD,KAAK,GAAG,CAC/D,CAAC;IACJ,CAAC;IAED,IAAI,KAAK,KAAK,CAAC,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7C,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,IAAI,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC3C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,aAAa,CACrB,uBAAuB,EACvB,2BAA2B,KAAK,GAAG,CACpC,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,SAAiB;IACvD,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,aAAa,CACrB,uBAAuB,EACvB,kCAAkC,SAAS,qCAAqC,CACjF,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,KAAa;IACpD,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AAC9C,CAAC","sourcesContent":["import { ChroneraError } from \"../errors/errors.js\";\n\nexport function isGregorianLeapYear(year: number): boolean {\n return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;\n}\n\nconst COMMON_YEAR_MONTH_DAYS = [\n 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,\n] as const;\n\nexport function daysInGregorianMonth(year: number, month: number): number {\n if (month < 1 || month > 12) {\n throw new ChroneraError(\n \"CHRONERA_INVALID_DATE\",\n `Gregorian month must be between 1 and 12; received ${month}.`,\n );\n }\n\n if (month === 2 && isGregorianLeapYear(year)) {\n return 29;\n }\n\n const days = COMMON_YEAR_MONTH_DAYS[month];\n if (days === undefined) {\n throw new ChroneraError(\n \"CHRONERA_INVALID_DATE\",\n `Invalid Gregorian month ${month}.`,\n );\n }\n\n return days;\n}\n\nexport function parseGregorianMonthCode(monthCode: string): number {\n if (!/^M(0[1-9]|1[0-2])$/.test(monthCode)) {\n throw new ChroneraError(\n \"CHRONERA_INVALID_DATE\",\n `Invalid Gregorian month code: \"${monthCode}\". Expected format M01 through M12.`,\n );\n }\n return Number.parseInt(monthCode.slice(1), 10);\n}\n\nexport function formatGregorianMonthCode(month: number): `M${string}` {\n return `M${String(month).padStart(2, \"0\")}`;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Instant } from "../public-types.js";
|
|
2
|
+
export declare const MIN_EPOCH_MILLISECONDS = -62135596800000;
|
|
3
|
+
export declare const MAX_EPOCH_MILLISECONDS = 253402300799999;
|
|
4
|
+
export declare function instantFromEpochMilliseconds(epochMilliseconds: number): Instant;
|
|
5
|
+
export declare function instantFromDate(date: Date): Instant;
|
|
6
|
+
export declare function instantFromEpochSeconds(epochSeconds: number): Instant;
|