@zodiacs/engine 0.1.1-rc.14 → 0.1.1-rc.16
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 +797 -6
- package/LICENSING.md +354 -21
- package/NOTICE +166 -9
- package/README.md +327 -84
- package/dist/api-VOW6Umy5.d.ts +197 -0
- package/dist/calc.d.ts +279 -0
- package/dist/calc.js +853 -0
- package/dist/{chunk-NAJ735VN.js → chunk-2OWGBT3O.js} +1 -1
- package/dist/{chunk-4OSOCZY2.js → chunk-4NV4ZEFZ.js} +21 -6
- package/dist/chunk-A3U2ZS2W.js +29 -0
- package/dist/chunk-I7O5EGFV.js +25 -0
- package/dist/chunk-KFTJMMG7.js +61 -0
- package/dist/chunk-KHBLFXFG.js +227 -0
- package/dist/chunk-L6ZHWJZ6.js +355 -0
- package/dist/chunk-N4B5JNMA.js +473 -0
- package/dist/chunk-O3NJRGJ2.js +56 -0
- package/dist/{chunk-RETEVD4F.js → chunk-WOU7JVD3.js} +293 -154
- package/dist/crossings.d.ts +1 -1
- package/dist/deltat.d.ts +8 -8
- package/dist/geo.d.ts +137 -8
- package/dist/geo.js +28 -166
- package/dist/houses-extra.d.ts +81 -0
- package/dist/houses-extra.js +337 -0
- package/dist/houses-q1O2GGp4.d.ts +128 -0
- package/dist/index.d.ts +8 -201
- package/dist/index.js +38 -315
- package/dist/internal-math-CmJ9xtaW.d.ts +160 -0
- package/dist/internal-math.d.ts +3 -2
- package/dist/internal-math.js +2 -2
- package/dist/internal.d.ts +2 -1
- package/dist/internal.js +4 -4
- package/dist/receipt.d.ts +74 -29
- package/dist/receipt.js +194 -33
- package/dist/rulers-9wljfVaO.d.ts +10 -0
- package/dist/sky.d.ts +158 -0
- package/dist/sky.js +377 -0
- package/dist/techniques.d.ts +410 -0
- package/dist/techniques.js +830 -0
- package/dist/timing.d.ts +473 -0
- package/dist/timing.js +904 -0
- package/dist/{types-CeafogFp.d.ts → types-B4MCoCCS.d.ts} +35 -4
- package/dist/tzdb-2025c-00-6GVG6RYL.js +6 -0
- package/dist/tzdb-2025c-01-CEYMG3LE.js +6 -0
- package/dist/tzdb-2025c-02-NWQJCVUU.js +6 -0
- package/dist/tzdb-2025c-03-PLHP6VH4.js +6 -0
- package/dist/tzdb-2025c-04-MEKUJA6M.js +6 -0
- package/dist/tzdb-2025c-05-3K5YKZBL.js +6 -0
- package/dist/tzdb-2025c-06-L2VV5XJV.js +6 -0
- package/dist/tzdb-2025c-07-H3GLGJGY.js +6 -0
- package/dist/tzdb-2025c-08-DA7QQIGD.js +6 -0
- package/dist/tzdb-2025c-09-MTXIO3QL.js +6 -0
- package/dist/tzdb-2025c-10-ASL4UW5C.js +6 -0
- package/dist/tzdb-2025c-11-EQEOANYB.js +6 -0
- package/dist/tzdb-2025c-12-NKCCXJ5G.js +6 -0
- package/dist/tzdb-2025c-13-DYTF3UC7.js +6 -0
- package/dist/tzdb-2025c-14-C25H45R5.js +6 -0
- package/dist/tzdb-2025c-15-7OYYZWRY.js +6 -0
- package/dist/vedic.d.ts +393 -0
- package/dist/vedic.js +930 -0
- package/dist/window.d.ts +178 -0
- package/dist/window.js +961 -0
- package/package.json +31 -3
- package/dist/chunk-GFT24GFR.js +0 -25
- package/dist/internal-math-BE2hcSHd.d.ts +0 -271
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
import {
|
|
2
|
+
civilDateOf,
|
|
3
|
+
format,
|
|
4
|
+
julianDayNumber,
|
|
5
|
+
parseCalendarDate
|
|
6
|
+
} from "./chunk-KFTJMMG7.js";
|
|
7
|
+
import {
|
|
8
|
+
validateBirthSettings
|
|
9
|
+
} from "./chunk-PFGUCNOK.js";
|
|
10
|
+
|
|
11
|
+
// src/geo/calendar.ts
|
|
12
|
+
var GREGORIAN_ADOPTION_SOURCES = Object.freeze({
|
|
13
|
+
tzdb: "IANA tzdata 2025c, file calendars, quoting H. Grotefend, Taschenbuch der Zeitrechnung, ed. O. Grotefend (1941), pp. 26-28",
|
|
14
|
+
"grotefend-1891": "H. Grotefend, Zeitrechnung des deutschen Mittelalters und der Neuzeit, vol. 1 (1891), pp. 133-134",
|
|
15
|
+
"grotefend-1898": "H. Grotefend, Taschenbuch der Zeitrechnung des deutschen Mittelalters und der Neuzeit (1898), pp. 23-24"
|
|
16
|
+
});
|
|
17
|
+
var ROWS = `AT|Austria|Austria|1584-01-17|t|Grotefend 1898: 1583-10-16, with Bavaria. Salzburg 1583-10-16; Styria 1583-12-25.
|
|
18
|
+
BE|Belgium|Brabant, Flanders, Hainaut|1583-01-01|t|Grotefend 1891, 1898: 1582-12-25. Bishopric of Li\xE8ge 1583-02-21.
|
|
19
|
+
CH|Switzerland|Z\xFCrich, Bern, Basel, Schaffhausen|1701-01-12|t18|Also Geneva and Thurgau. Catholic cantons 1584-01-22 (Grotefend 1891: 1584-01-23); Unterwalden June 1584; Glarus, Appenzell, St. Gallen city 1724; Valais 1655 (Grotefend 1898: 1622); Graub\xFCnden 1760-1812 (Grotefend 1898: to 1811); bishopric of Basel 1583-10-31.
|
|
20
|
+
CZ|Czech Republic|Bohemia|1584-01-17|t18|Silesia 1584-01-23. Moravia is not dated.
|
|
21
|
+
DE|Germany|Protestant states|1700-03-01|t18|Catholic states from 1583: bishopric of Augsburg 1583-02-24, Bavaria 1583-10-16, the latest listed the bishopric of Hildesheim 1631-03-26.
|
|
22
|
+
DK|Denmark|-|1700-03-01|t18|
|
|
23
|
+
ES|Spain|-|1582-10-15|t18|
|
|
24
|
+
FI|Finland|-|1753-03-01|t|With Sweden; see Sweden. tzdb's list says the Russian empire, Finland included, kept the Julian calendar until 1917.
|
|
25
|
+
FR|France|France, Lorraine|1582-12-20|t18|City of Strasbourg 1682-02-16; bishopric of Strasbourg 1583-11-27 (Grotefend 1898: 1583-11-22); Austrian Upper Alsace 1583-10-24. Republican calendar 1793-11-24 to 1805-12-31, in Paris also 1871-05-06 to 1871-05-23: not converted.
|
|
26
|
+
GB|Britain (UK)|Great Britain|1752-09-14|t18|
|
|
27
|
+
HU|Hungary|-|1587-11-01|t18|The legal change. tzdb's list also gives 1584-02-02, "legally on 21 Oct 1587".
|
|
28
|
+
IT|Italy|Italy, with exceptions|1582-10-15|t18|Bishopric of Brixen (Bressanone) 1583-10-16.
|
|
29
|
+
NL|Netherlands|Holland|1583-01-01|t|Grotefend 1891, 1898: 1582-12-25. Gelderland 1700-07-12; Zutphen 1700-07-12 (Grotefend 1898: 1700-12-12); Utrecht, Overijssel 1700-12-12; Friesland, Groningen 1701-01-12; Grotefend 1891: 1700-12-12 for all six. Zeeland and Drenthe are not dated.
|
|
30
|
+
NO|Norway|-|1700-03-01|t|Grotefend 1891, 1898 name Denmark only.
|
|
31
|
+
PL|Poland|Roman Catholics, and Danzig|1582-10-15|t|Grotefend 1898: not everywhere, notably not among Protestants and the Greek Church; Grotefend 1891: 1586. Silesia 1584-01-23; duchy of Prussia 1612-09-02 (Grotefend 1898: 1612-09-01).
|
|
32
|
+
PT|Portugal|-|1582-10-15|t18|
|
|
33
|
+
RU|Russia|Soviet Russia|1918-02-14|t|Grotefend 1891, 1898: still Julian. Duchy of Prussia, now partly Kaliningrad, 1612-09-02 (Grotefend 1898: 1612-09-01).
|
|
34
|
+
SE|Sweden|-|1753-03-01|t18|From 1 March 1700 to 30 February 1712 Swedish dates are one day ahead of the Julian (Grotefend 1898).`;
|
|
35
|
+
var SOURCE_KEYS = { t: "tzdb", 1: "grotefend-1891", 8: "grotefend-1898" };
|
|
36
|
+
var GREGORIAN_ADOPTION = Object.freeze(
|
|
37
|
+
ROWS.split("\n").map((line) => {
|
|
38
|
+
const [code, country, region, firstGregorian, sources, note] = line.split("|");
|
|
39
|
+
const day = julianDayNumber(parseCalendarDate(firstGregorian, "gregorian"), "gregorian");
|
|
40
|
+
return Object.freeze({
|
|
41
|
+
code,
|
|
42
|
+
country,
|
|
43
|
+
region: region === "-" ? null : region,
|
|
44
|
+
firstGregorian,
|
|
45
|
+
lastJulian: format(civilDateOf(day - 1, "julian")),
|
|
46
|
+
sources: Object.freeze([...sources].map((key) => SOURCE_KEYS[key])),
|
|
47
|
+
note
|
|
48
|
+
});
|
|
49
|
+
})
|
|
50
|
+
);
|
|
51
|
+
function gregorianAdoption(country) {
|
|
52
|
+
return GREGORIAN_ADOPTION.find((row) => row.code === country || row.country === country);
|
|
53
|
+
}
|
|
54
|
+
function calendarNote(gregorianDate, calendar, country) {
|
|
55
|
+
const adoption = gregorianAdoption(country);
|
|
56
|
+
if (!adoption) return null;
|
|
57
|
+
const julian = calendar === "julian";
|
|
58
|
+
if (gregorianDate >= adoption.firstGregorian) return julian ? { kind: "new-style", adoption } : null;
|
|
59
|
+
return julian ? null : { kind: "old-style", adoption };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/tzdb/tzdb-2025c.ts
|
|
63
|
+
var TZDB = Object.freeze({
|
|
64
|
+
version: "2025c",
|
|
65
|
+
sha256: "4aa79e4effee53fc4029ffe5f6ebe97937282ebcdf386d5d2da91ce84142f957",
|
|
66
|
+
form: "main+backzone"
|
|
67
|
+
});
|
|
68
|
+
var SHARD_LOADERS = [
|
|
69
|
+
() => import("./tzdb-2025c-00-6GVG6RYL.js"),
|
|
70
|
+
() => import("./tzdb-2025c-01-CEYMG3LE.js"),
|
|
71
|
+
() => import("./tzdb-2025c-02-NWQJCVUU.js"),
|
|
72
|
+
() => import("./tzdb-2025c-03-PLHP6VH4.js"),
|
|
73
|
+
() => import("./tzdb-2025c-04-MEKUJA6M.js"),
|
|
74
|
+
() => import("./tzdb-2025c-05-3K5YKZBL.js"),
|
|
75
|
+
() => import("./tzdb-2025c-06-L2VV5XJV.js"),
|
|
76
|
+
() => import("./tzdb-2025c-07-H3GLGJGY.js"),
|
|
77
|
+
() => import("./tzdb-2025c-08-DA7QQIGD.js"),
|
|
78
|
+
() => import("./tzdb-2025c-09-MTXIO3QL.js"),
|
|
79
|
+
() => import("./tzdb-2025c-10-ASL4UW5C.js"),
|
|
80
|
+
() => import("./tzdb-2025c-11-EQEOANYB.js"),
|
|
81
|
+
() => import("./tzdb-2025c-12-NKCCXJ5G.js"),
|
|
82
|
+
() => import("./tzdb-2025c-13-DYTF3UC7.js"),
|
|
83
|
+
() => import("./tzdb-2025c-14-C25H45R5.js"),
|
|
84
|
+
() => import("./tzdb-2025c-15-7OYYZWRY.js")
|
|
85
|
+
];
|
|
86
|
+
var LATER_CAUSES = "26z1v3r9wo.2lzdo.2092c.51mzc.;4omh4gkhm0.;8i4hw7ji4c.8fno.94cvo.;emnzt8v8m6.;pibsacwtc0.;shzcp6wjs0.609ic.14eec.;qn9anc1rqo.;hr04d6wjeo.609ic.14eec.;iwfdj6f1oo.;jxme485390.;vxtl73htjc.;zmgwf7egs0!;008wxcglro.4g1o.ie6c.3m1o.;xgck2d5eqc!;x90aj50d2u.;e4lpj23xc0.;n97c09emgo.6l9mc.;c1i1b2i6cc.;srkypcglq0.4970.il10.3lyc.1glac.fl5o.6hh0.4ypc.67h0.4t70.6hc1.4yqz.69p1.4yqz.69p1.4vjz.;6bx5p6nh2c.69c80.14eec.fzlo.;d7foo4bvj0.;da48bez4xo.;cc60723xc0.;r2ctm3r9wo.2lzdo.2092c.51mzc.;09xrhgo29o.;23q2c4g4g0.;2fq0m6nh2c.69c80.14eec.nrlo.;73ubg6wji0.609ic.14eec.;glme93r9mo.;iztuh9nq0c.;yksj0kmbc.;94mmz6nh2c.69c80.14eec.195lo.oeuc.;c9gx56mm3c.74rc.3y7yc.l5o.;ftdfk2i6cc.;fyvor6f1oo.;oqbaz9c9u0.;upch43ip7c.;4tlos3ofjo.38450.;bzp0f6wjn0.8fhf0.;cwffa6mm3c.74rc.;lal8k92wc0.;oyxuu31w40.4rwuc!;z0hat2fygi.bwwu.;091etgo29o.;blqvj6wjlc.f49c.5l5ao.14eec.jnto.;tgp36clt30.;9wqor23xc0.;vma32kmbc.;6vjgid5eoo!;agkxx6wji0.609ic.14eec.fznc.;bt63w1yu1o.;6fyvm6dbgo.;93ycg6f1oo.;jenq11pdmo.;kikwv6wjjo.609ic.14eec.;6i87mkmbc.;ktr4c6bdnc.tlnc.3mpic.3w1o.;lnqdp1pdmo.;x5jk0173j0.;ylrpy4bvj0.;yvsdoecogo.10ao0.;51sa56mm3c.74rc.3y7yc.l5o.;imjhpc1rsc.1onac.;xgvkj6tqo0.632mc.;4rg6l6wjd0.609k0.;cx7tr6mm3c.74rc.;e7mcw6wjlc.609ic.14eec.;3se9a6dbgo.;8k2bmkmbc.;nkww16bdnc.hxnc.;sjll11ibsc.856ho.12w0.;tbefcc1rsc.1onac.;v730i4n7yc.;dvg44kmbc.;v977f6mm3c.74rc.3y7yc.ddo.;7egrqe35eo.;lgxqt4g4g0.k8uc.;8hz4v6mm3c.74rc.3y7yc.l5o.;pyva5q8v0.;npf8s6wjn0.a2170.;x1w033is10.3drdo.609ic.58r0.z5p0.;068n925yo0.;kjcdu4m9pu.;b0ken2i6e0.;e0yew2i6cc.;pfxgu6wjn0.609ic.14eec.;4oapw3r3pc.9lic.;9linmuzqo.gvqc.;z70s311v0q6_;zme5q6wjoo.a215c.;oh15y11je0.k8uc.5a80c.88fo.321o.193ac.;blv5h6mjvc.22jc.43cec.l5o.;d7hxtkmbc.;jvnzr6f1oo.;wrz6f32nac.h2ho.;x7xki3r9mo.;0aanqasrbo.8fio.;foc486wjoo.609ic.14eec.;wh9055mw2o.;04yj4kmbc.;31xyt6wjeo.609ic.14eec.gurc.;k0dlb4n7yc.;k4x616wjeo.609k0.14eec.fzlo.;qsklxf141o.b9k0.;d90416wjlc.11sxc.4ygmo.14eec.fzlo.;diqxz9emgo.5klmc.;hqu65r7tc.;r60tt9c9u0.;7hozj7egs0!;n4f883r3pc.bjf0.4vl5o.560rc.;rcx29bn8lc.;tyfb56wjoo.;3mwwdr7tc.;h2j0f6wjoo.;n3exs6wjgc.609ic.14eec.;pf3zccwtc0.14eec.;3wlms4692o.8kazc.;hjhq6852vo.;yded86mm3c.74rc.;cshzubvnvo.2mmo0.;mkxe53htjc.;u226p6mm3c.74rc.;v8ck8774zc.5b2c.;xy1qbcgltc.;s3w2g3ofjo.38450.u8uc.;58co631w1s.4rwuw!;x8ghc1uhio.;y3thu2fygi.bwwu.;u3e1j1qwm9.57t4f.;cga095k1yu.;7xj8c6wjs0.609ic.14eec.;5m66y6wjlc.37w6c.2sddo.14eec.hxlo.;69icl31w40.4rwuc!;mu12m6bdnc.tlnc.3mpic.3w1o.;odp3marwl0.ndo.;otx0189jyu.4r36.2yq8u.;sxc0n6nh2c.69c80.14eec.;mez0y6wjoo.;tsxgk3r9mo.;2447s1zep0.7ms9o.;3s5e6c1rsc.1onac.;983km2uo86.;qbuhn50d2u.;qslwbe5bvo.;u0hxf6wji0.3qpv0.29jlo.58r0.z5p0.;cft6i6borc.dpfc.42jic.1p5o.13cko.jezc.;6o3pl3uzh0.;ertoo6wjs0.609ic.14eec.fzlo.;h5uvn5k1yu.;sa6yk50dkc.;4q92r6bdnc.hxnc.;wfyr46wjoo.;7zfow2rx5i.;j06xje5c0o.;teiet4bvo0.;6v8ej6mjvc.22jc.43bac.1p5o.;ajtnw2x3so.;ttwf6ea8x0.uog0.;o6n0f6wjlc.609k0.;4bqjbaryt0.l5o.;j9sdo38geo.;0hdnqebsg6.;6qmtw6f1qc.177go.68h90.6h8o.;asm1e4n7yc.;kzndtc1rsc.1onac.;mmp3d1kcxo.;pjzkh6wjd0.609k0.";
|
|
87
|
+
|
|
88
|
+
// src/geo/zone-history.ts
|
|
89
|
+
var CAUSES = { d: "dst", l: "legal-change", x: "date-line" };
|
|
90
|
+
function nameHash(name) {
|
|
91
|
+
const key = name.toLowerCase();
|
|
92
|
+
let hash = 2166136261;
|
|
93
|
+
for (let index = 0; index < key.length; index += 1) {
|
|
94
|
+
hash ^= key.charCodeAt(index);
|
|
95
|
+
hash = Math.imul(hash, 16777619) >>> 0;
|
|
96
|
+
}
|
|
97
|
+
return hash;
|
|
98
|
+
}
|
|
99
|
+
function decode(entry) {
|
|
100
|
+
const times = [];
|
|
101
|
+
let previous = 0;
|
|
102
|
+
if (entry.t) {
|
|
103
|
+
entry.t.split(",").forEach((part, index) => {
|
|
104
|
+
const value = parseInt(part, 36);
|
|
105
|
+
previous = index === 0 ? value : previous + value;
|
|
106
|
+
times.push(previous * 1e3);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
const types = [0];
|
|
110
|
+
const causes = [];
|
|
111
|
+
for (let index = 0; index < entry.k.length; index += 2) {
|
|
112
|
+
types.push(parseInt(entry.k[index], 36));
|
|
113
|
+
causes.push(CAUSES[entry.k[index + 1]]);
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
name: entry.n,
|
|
117
|
+
source: entry.s,
|
|
118
|
+
hostLegal: entry.h === 1,
|
|
119
|
+
zoneEraEnd: entry.f === null ? null : entry.f * 1e3,
|
|
120
|
+
era: entry.e ? entry.e.map(([until, offset]) => [until * 1e3, offset]) : null,
|
|
121
|
+
times,
|
|
122
|
+
types,
|
|
123
|
+
causes,
|
|
124
|
+
offsets: entry.y.map((type) => type[0]),
|
|
125
|
+
dst: entry.y.map((type) => type[1] === 1),
|
|
126
|
+
abbreviations: entry.y.map((type) => type[2])
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
var histories = /* @__PURE__ */ new Map();
|
|
130
|
+
var loads = /* @__PURE__ */ new Map();
|
|
131
|
+
function loadedHistory(timeZone) {
|
|
132
|
+
return histories.get(timeZone.toLowerCase());
|
|
133
|
+
}
|
|
134
|
+
function loadHistory(timeZone) {
|
|
135
|
+
const key = timeZone.toLowerCase();
|
|
136
|
+
if (histories.has(key)) return Promise.resolve();
|
|
137
|
+
const bucket = nameHash(timeZone) % SHARD_LOADERS.length;
|
|
138
|
+
let pending = loads.get(bucket);
|
|
139
|
+
if (!pending) {
|
|
140
|
+
const load = SHARD_LOADERS[bucket]().then((module) => module.default);
|
|
141
|
+
loads.set(bucket, load);
|
|
142
|
+
void load.catch(() => {
|
|
143
|
+
if (loads.get(bucket) === load) loads.delete(bucket);
|
|
144
|
+
});
|
|
145
|
+
pending = load;
|
|
146
|
+
}
|
|
147
|
+
const ready = pending.then((zones) => {
|
|
148
|
+
const entry = Object.prototype.hasOwnProperty.call(zones, key) ? zones[key] : void 0;
|
|
149
|
+
histories.set(key, entry ? decode(entry) : null);
|
|
150
|
+
});
|
|
151
|
+
void ready.catch(() => {
|
|
152
|
+
});
|
|
153
|
+
return ready;
|
|
154
|
+
}
|
|
155
|
+
function typeIndexAt(history, ms) {
|
|
156
|
+
let lo = 0;
|
|
157
|
+
let hi = history.times.length;
|
|
158
|
+
while (lo < hi) {
|
|
159
|
+
const mid = lo + hi >> 1;
|
|
160
|
+
if (history.times[mid] <= ms) lo = mid + 1;
|
|
161
|
+
else hi = mid;
|
|
162
|
+
}
|
|
163
|
+
return lo;
|
|
164
|
+
}
|
|
165
|
+
function transitionAt(history, ms) {
|
|
166
|
+
const index = typeIndexAt(history, ms) - 1;
|
|
167
|
+
return index >= 0 && history.times[index] === ms ? index : -1;
|
|
168
|
+
}
|
|
169
|
+
var later;
|
|
170
|
+
function laterCause(timeZone, ms) {
|
|
171
|
+
if (!later) {
|
|
172
|
+
later = /* @__PURE__ */ new Map();
|
|
173
|
+
for (const row of LATER_CAUSES.split(";")) {
|
|
174
|
+
const causes = /* @__PURE__ */ new Map();
|
|
175
|
+
let at = 0;
|
|
176
|
+
for (const [, digits, mark] of row.slice(5).matchAll(/([0-9a-z]+)([.!_~])/g)) {
|
|
177
|
+
const kind = ".!_~".indexOf(mark);
|
|
178
|
+
at += parseInt(digits, 36) * (kind < 2 ? 6e4 : 1e3);
|
|
179
|
+
causes.set(at, kind % 2 ? "date-line" : "legal-change");
|
|
180
|
+
}
|
|
181
|
+
later.set(parseInt(row.slice(0, 5), 36), causes);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return later.get(nameHash(timeZone) % 36 ** 5)?.get(ms) ?? "dst";
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// src/geo/timezone.ts
|
|
188
|
+
var offsetFormatters = /* @__PURE__ */ new Map();
|
|
189
|
+
function validateTimeZone(timeZone) {
|
|
190
|
+
if (typeof timeZone !== "string" || timeZone.trim().length === 0) {
|
|
191
|
+
throw new RangeError("timeZone must be an explicit nonempty timezone string.");
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function offsetFormatter(timeZone) {
|
|
195
|
+
validateTimeZone(timeZone);
|
|
196
|
+
let formatter = offsetFormatters.get(timeZone);
|
|
197
|
+
if (!formatter) {
|
|
198
|
+
formatter = new Intl.DateTimeFormat("en-US", {
|
|
199
|
+
timeZone,
|
|
200
|
+
calendar: "gregory",
|
|
201
|
+
numberingSystem: "latn",
|
|
202
|
+
timeZoneName: "longOffset"
|
|
203
|
+
});
|
|
204
|
+
offsetFormatters.set(timeZone, formatter);
|
|
205
|
+
}
|
|
206
|
+
return formatter;
|
|
207
|
+
}
|
|
208
|
+
function validateInstant(utcMilliseconds) {
|
|
209
|
+
if (typeof utcMilliseconds !== "number" || !Number.isFinite(utcMilliseconds)) {
|
|
210
|
+
throw new RangeError("utcMilliseconds must be a finite epoch-millisecond timestamp.");
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function offsetAt(timeZone, utcMilliseconds) {
|
|
214
|
+
validateInstant(utcMilliseconds);
|
|
215
|
+
const name = offsetFormatter(timeZone).formatToParts(utcMilliseconds).find((part) => part.type === "timeZoneName")?.value;
|
|
216
|
+
const match = (name ?? "GMT").match(/^GMT(?:([+-])(\d{1,2})(?::(\d{2}))?(?::(\d{2}))?)?$/u);
|
|
217
|
+
if (!match) {
|
|
218
|
+
throw new RangeError(`Could not read UTC offset for timezone: ${timeZone}`);
|
|
219
|
+
}
|
|
220
|
+
const sign = match[1] === "-" ? -1 : 1;
|
|
221
|
+
return sign * (Number(match[2] ?? 0) * 60 + Number(match[3] ?? 0) + Number(match[4] ?? 0) / 60);
|
|
222
|
+
}
|
|
223
|
+
var DAY = 864e5;
|
|
224
|
+
var PROBE = 36 * 36e5;
|
|
225
|
+
var MAX_DEPARTURE_SECONDS = 180 * 60;
|
|
226
|
+
var FIXED_ZONE = /^(?:etc\/)?(?:utc|uct|gmt|gmt0|gmt[+-]0|greenwich|universal|zulu)$|^etc\/gmt[+-]\d{1,2}$/iu;
|
|
227
|
+
function hostTzdbVersion() {
|
|
228
|
+
const tz = globalThis.process?.versions?.tz;
|
|
229
|
+
return typeof tz === "string" && /^\d{4}[a-z]$/u.test(tz) ? tz : null;
|
|
230
|
+
}
|
|
231
|
+
function firstChange(clockAt, lo, hi) {
|
|
232
|
+
const from = clockAt(lo);
|
|
233
|
+
while (hi - lo > 1) {
|
|
234
|
+
const mid = Math.floor((lo + hi) / 2);
|
|
235
|
+
if (clockAt(mid) === from) lo = mid;
|
|
236
|
+
else hi = mid;
|
|
237
|
+
}
|
|
238
|
+
return hi;
|
|
239
|
+
}
|
|
240
|
+
function readClock(wallMs, clockAt, samples) {
|
|
241
|
+
const readings = [];
|
|
242
|
+
for (const offset of new Set(samples.map(clockAt))) {
|
|
243
|
+
const utcMs2 = wallMs - offset * 1e3;
|
|
244
|
+
if (clockAt(utcMs2) === offset && !readings.some((reading) => reading.utcMs === utcMs2)) {
|
|
245
|
+
readings.push({ utcMs: utcMs2, offset });
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const [first, second] = readings.sort((a, b) => a.utcMs - b.utcMs);
|
|
249
|
+
if (first) {
|
|
250
|
+
return second ? { chosen: first, kind: "fold", at: firstChange(clockAt, first.utcMs, second.utcMs) } : { chosen: first, kind: null, at: null };
|
|
251
|
+
}
|
|
252
|
+
let lo = wallMs - PROBE - DAY;
|
|
253
|
+
let hi = wallMs + PROBE + DAY;
|
|
254
|
+
while (hi - lo > 1) {
|
|
255
|
+
const mid = Math.floor((lo + hi) / 2);
|
|
256
|
+
if (mid + clockAt(mid) * 1e3 > wallMs) hi = mid;
|
|
257
|
+
else lo = mid;
|
|
258
|
+
}
|
|
259
|
+
const utcMs = wallMs - clockAt(lo) * 1e3;
|
|
260
|
+
return { chosen: { utcMs, offset: clockAt(utcMs) }, kind: "gap", at: hi };
|
|
261
|
+
}
|
|
262
|
+
function zoneClock(timeZone, history) {
|
|
263
|
+
return (ms) => {
|
|
264
|
+
const offset = history && ms < 0 ? history.offsets[history.types[typeIndexAt(history, ms)]] : null;
|
|
265
|
+
return offset ?? Math.round(offsetAt(timeZone, ms) * 60);
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function birthplaceClock(history, wallMs, longitude, zoneAt) {
|
|
269
|
+
const era = history.era;
|
|
270
|
+
if (!era) return null;
|
|
271
|
+
const endMs = era[era.length - 1][0];
|
|
272
|
+
if (wallMs - PROBE > endMs) return null;
|
|
273
|
+
const meanSeconds = Math.round(longitude * 240);
|
|
274
|
+
const eraOffset = (ms) => (era.find(([until]) => ms < until) ?? era[era.length - 1])[1];
|
|
275
|
+
const place = (ms) => meanSeconds + Math.round((eraOffset(ms) - meanSeconds) / 86400) * 86400;
|
|
276
|
+
const sample = Math.min(wallMs, endMs - 1);
|
|
277
|
+
if (Math.abs(place(sample) - eraOffset(sample)) > MAX_DEPARTURE_SECONDS) return null;
|
|
278
|
+
const legalFrom = history.hostLegal && zoneAt(endMs + PROBE) !== zoneAt(endMs) ? firstChange(zoneAt, endMs, endMs + PROBE) : endMs;
|
|
279
|
+
return {
|
|
280
|
+
clockAt: (ms) => ms < endMs ? place(ms) : zoneAt(Math.max(ms, legalFrom)),
|
|
281
|
+
endMs,
|
|
282
|
+
legalFrom,
|
|
283
|
+
/** The era's own line ends before endMs: moves across the date line. */
|
|
284
|
+
lineEnds: era.slice(0, -1).map(([until]) => until)
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
function readOptions(options) {
|
|
288
|
+
if (options === void 0) return { calendar: "gregorian" };
|
|
289
|
+
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
290
|
+
throw new RangeError("options must be an object.");
|
|
291
|
+
}
|
|
292
|
+
for (const key of Object.getOwnPropertyNames(options)) {
|
|
293
|
+
if (!["longitude", "calendar", "country"].includes(key)) throw new RangeError(`Unknown local time option "${key}".`);
|
|
294
|
+
}
|
|
295
|
+
const { longitude, calendar = "gregorian", country } = options;
|
|
296
|
+
if (longitude !== void 0 && !(typeof longitude === "number" && Math.abs(longitude) <= 180)) {
|
|
297
|
+
throw new RangeError("longitude must be between -180 and 180 degrees.");
|
|
298
|
+
}
|
|
299
|
+
if (calendar !== "gregorian" && calendar !== "julian") throw new RangeError('calendar must be "gregorian" or "julian".');
|
|
300
|
+
if (country !== void 0 && (typeof country !== "string" || !country.trim())) {
|
|
301
|
+
throw new RangeError("country must be a nonempty string.");
|
|
302
|
+
}
|
|
303
|
+
return { longitude, calendar, country };
|
|
304
|
+
}
|
|
305
|
+
var pad = (value, width = 2) => String(value).padStart(width, "0");
|
|
306
|
+
function resolveLocalToUtc(date, time, timeZone, options) {
|
|
307
|
+
offsetFormatter(timeZone);
|
|
308
|
+
const { longitude, calendar, country } = readOptions(options);
|
|
309
|
+
const written = parseCalendarDate(date, calendar);
|
|
310
|
+
const hhmm = typeof time === "string" ? /^([01]\d|2[0-3]):([0-5]\d)$/u.exec(time) : null;
|
|
311
|
+
if (!written || !hhmm) {
|
|
312
|
+
throw new RangeError(`Local date/time must be a ${calendar === "julian" ? "Julian" : "Gregorian"} date YYYY-MM-DD and a time HH:MM.`);
|
|
313
|
+
}
|
|
314
|
+
const civil = calendar === "julian" ? civilDateOf(julianDayNumber(written, "julian"), "gregorian") : written;
|
|
315
|
+
if (civil.year < 0) throw new RangeError("The Julian date falls before the Gregorian year 0000.");
|
|
316
|
+
const gregorianDate = `${pad(civil.year, 4)}-${pad(civil.month)}-${pad(civil.day)}`;
|
|
317
|
+
const wall = /* @__PURE__ */ new Date(0);
|
|
318
|
+
wall.setUTCFullYear(civil.year, civil.month - 1, civil.day);
|
|
319
|
+
const wallMs = wall.setUTCHours(Number(hhmm[1]), Number(hhmm[2]));
|
|
320
|
+
const loaded = FIXED_ZONE.test(timeZone) ? null : loadedHistory(timeZone);
|
|
321
|
+
if (loaded === void 0 && wallMs < DAY) throw notLoaded();
|
|
322
|
+
const history = loaded ?? null;
|
|
323
|
+
const zoneAt = zoneClock(timeZone, history);
|
|
324
|
+
const place = longitude !== void 0 && history ? birthplaceClock(history, wallMs, longitude, zoneAt) : null;
|
|
325
|
+
const samples = [wallMs - PROBE, wallMs, wallMs + PROBE, ...place ? [place.endMs - 1, place.endMs, place.legalFrom] : []];
|
|
326
|
+
const clockAt = place ? place.clockAt : zoneAt;
|
|
327
|
+
const zoneReading = readClock(wallMs, zoneAt, samples);
|
|
328
|
+
const reading = place ? readClock(wallMs, clockAt, samples) : zoneReading;
|
|
329
|
+
const { chosen, kind } = reading;
|
|
330
|
+
const inEra = !!place && chosen.utcMs < place.endMs;
|
|
331
|
+
const count = history && chosen.utcMs < 0 ? typeIndexAt(history, chosen.utcMs) : -1;
|
|
332
|
+
const type = count < 0 ? -1 : history.types[count];
|
|
333
|
+
const shipped = inEra || type >= 0 && history.offsets[type] !== null;
|
|
334
|
+
let applied = reading.at;
|
|
335
|
+
if (applied === null && shipped) {
|
|
336
|
+
const recorded = count > 0 ? history.times[count - 1] : null;
|
|
337
|
+
const marks = place ? [...place.lineEnds, place.endMs, place.legalFrom].filter((at) => at <= chosen.utcMs) : [];
|
|
338
|
+
if (recorded !== null && (!place || recorded >= place.legalFrom)) marks.push(recorded);
|
|
339
|
+
applied = marks.length ? Math.max(...marks) : null;
|
|
340
|
+
}
|
|
341
|
+
let transition = null;
|
|
342
|
+
if (applied !== null) {
|
|
343
|
+
const at = applied;
|
|
344
|
+
const before = clockAt(at - 1);
|
|
345
|
+
const after = clockAt(at);
|
|
346
|
+
const recorded = history && at < 0 ? transitionAt(history, at) : -1;
|
|
347
|
+
transition = {
|
|
348
|
+
at: new Date(at).toISOString(),
|
|
349
|
+
offsetBeforeMinutes: before / 60,
|
|
350
|
+
offsetAfterMinutes: after / 60,
|
|
351
|
+
cause: Math.abs(after - before) >= 43200 ? "date-line" : place && (at === place.endMs || at === place.legalFrom) ? "legal-change" : recorded >= 0 ? history.causes[recorded] : laterCause(timeZone, at)
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
const lmt = inEra || !place && history?.zoneEraEnd != null && chosen.utcMs < history.zoneEraEnd;
|
|
355
|
+
const flags = kind ? [kind === "gap" ? "dst-gap" : "dst-fold"] : [];
|
|
356
|
+
if (lmt) flags.push("lmt");
|
|
357
|
+
const localMeanTime = longitude !== void 0 && place && (inEra || kind === "gap" && reading.at === place.endMs) ? { longitude, zoneOffsetMinutes: zoneReading.chosen.offset / 60 } : null;
|
|
358
|
+
const zone = shipped ? {
|
|
359
|
+
source: "tzdb",
|
|
360
|
+
tzdbVersion: TZDB.version,
|
|
361
|
+
dataForm: history.hostLegal ? "main" : "main+backzone",
|
|
362
|
+
abbreviation: inEra ? null : history.abbreviations[type],
|
|
363
|
+
dst: !inEra && history.dst[type]
|
|
364
|
+
} : { source: "intl", tzdbVersion: hostTzdbVersion(), dataForm: "host", abbreviation: null, dst: null };
|
|
365
|
+
const offsetMinutes = chosen.offset / 60;
|
|
366
|
+
return {
|
|
367
|
+
utc: new Date(chosen.utcMs),
|
|
368
|
+
offsetMinutes,
|
|
369
|
+
flags,
|
|
370
|
+
date: gregorianDate,
|
|
371
|
+
writtenDate: date,
|
|
372
|
+
calendar,
|
|
373
|
+
jump: kind && transition ? { kind, cause: transition.cause } : null,
|
|
374
|
+
transition,
|
|
375
|
+
localMeanTime,
|
|
376
|
+
zone,
|
|
377
|
+
intlOffsetMinutes: shipped ? offsetAt(timeZone, chosen.utcMs) : null,
|
|
378
|
+
calendarNote: country === void 0 ? null : calendarNote(gregorianDate, calendar, country),
|
|
379
|
+
localResolution: {
|
|
380
|
+
date: gregorianDate,
|
|
381
|
+
time,
|
|
382
|
+
timeZone,
|
|
383
|
+
offsetMinutes,
|
|
384
|
+
gapShiftMinutes: kind === "gap" && transition ? transition.offsetAfterMinutes - transition.offsetBeforeMinutes : 0,
|
|
385
|
+
policy: { fold: "earlier", gap: "shift-forward" },
|
|
386
|
+
calendar,
|
|
387
|
+
writtenDate: date,
|
|
388
|
+
tzdbVersion: zone.tzdbVersion,
|
|
389
|
+
dataForm: zone.dataForm,
|
|
390
|
+
clock: lmt ? "local-mean-time" : "legal",
|
|
391
|
+
transition,
|
|
392
|
+
localMeanTime
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
function prepareLocalTime(date, timeZone) {
|
|
397
|
+
try {
|
|
398
|
+
if (typeof date !== "string" || !/^\d{4}-\d{2}-\d{2}$/u.test(date)) throw new RangeError("date must be YYYY-MM-DD.");
|
|
399
|
+
offsetFormatter(timeZone);
|
|
400
|
+
} catch (error) {
|
|
401
|
+
return Promise.reject(error);
|
|
402
|
+
}
|
|
403
|
+
return Number(date.slice(0, 4)) > 1970 || FIXED_ZONE.test(timeZone) ? Promise.resolve() : loadHistory(timeZone);
|
|
404
|
+
}
|
|
405
|
+
function zoneOffsetAt(timeZone, utcMilliseconds) {
|
|
406
|
+
validateInstant(utcMilliseconds);
|
|
407
|
+
offsetFormatter(timeZone);
|
|
408
|
+
const loaded = FIXED_ZONE.test(timeZone) ? null : loadedHistory(timeZone);
|
|
409
|
+
if (loaded === void 0 && utcMilliseconds < 0) throw notLoaded();
|
|
410
|
+
return zoneClock(timeZone, loaded ?? null)(utcMilliseconds) / 60;
|
|
411
|
+
}
|
|
412
|
+
function notLoaded() {
|
|
413
|
+
return new Error("The zone's history before 1970 is not loaded: await prepareLocalTime(date, timeZone) first.");
|
|
414
|
+
}
|
|
415
|
+
var LOCAL_BIRTH_KEYS = [
|
|
416
|
+
"date",
|
|
417
|
+
"time",
|
|
418
|
+
"timeZone",
|
|
419
|
+
"latitude",
|
|
420
|
+
"longitude",
|
|
421
|
+
"houseSystem",
|
|
422
|
+
"timeKnown",
|
|
423
|
+
"calendar",
|
|
424
|
+
"country"
|
|
425
|
+
];
|
|
426
|
+
function resolveLocalBirth(input) {
|
|
427
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
428
|
+
throw new RangeError("birth must be an object containing a local date and timezone.");
|
|
429
|
+
}
|
|
430
|
+
for (const key of Object.getOwnPropertyNames(input)) {
|
|
431
|
+
if (!LOCAL_BIRTH_KEYS.includes(key)) throw new RangeError(`Unknown local birth field "${key}".`);
|
|
432
|
+
}
|
|
433
|
+
const fields = Object.fromEntries(LOCAL_BIRTH_KEYS.map((key) => [key, input[key]]));
|
|
434
|
+
const settings = validateBirthSettings(fields);
|
|
435
|
+
const time = fields.time;
|
|
436
|
+
const timeKnown = settings.timeKnown ?? time !== void 0;
|
|
437
|
+
if (timeKnown && time === void 0) {
|
|
438
|
+
throw new RangeError("time is required when timeKnown is true.");
|
|
439
|
+
}
|
|
440
|
+
const resolution = resolveLocalToUtc(fields.date, time === void 0 ? "12:00" : time, fields.timeZone, {
|
|
441
|
+
longitude: settings.longitude,
|
|
442
|
+
calendar: fields.calendar,
|
|
443
|
+
country: fields.country
|
|
444
|
+
});
|
|
445
|
+
return {
|
|
446
|
+
birth: {
|
|
447
|
+
utc: resolution.utc,
|
|
448
|
+
timeKnown,
|
|
449
|
+
houseSystem: settings.houseSystem ?? "whole",
|
|
450
|
+
flags: resolution.flags,
|
|
451
|
+
...settings.latitude === void 0 ? {} : { latitude: settings.latitude, longitude: settings.longitude }
|
|
452
|
+
},
|
|
453
|
+
resolution,
|
|
454
|
+
reference: time === void 0 ? "local-noon" : "supplied-instant"
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
function resolveBirth(input) {
|
|
458
|
+
return resolveLocalBirth(input).birth;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export {
|
|
462
|
+
GREGORIAN_ADOPTION_SOURCES,
|
|
463
|
+
GREGORIAN_ADOPTION,
|
|
464
|
+
gregorianAdoption,
|
|
465
|
+
calendarNote,
|
|
466
|
+
TZDB,
|
|
467
|
+
offsetAt,
|
|
468
|
+
resolveLocalToUtc,
|
|
469
|
+
prepareLocalTime,
|
|
470
|
+
zoneOffsetAt,
|
|
471
|
+
resolveLocalBirth,
|
|
472
|
+
resolveBirth
|
|
473
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
eclipticFrame
|
|
3
|
+
} from "./chunk-WOU7JVD3.js";
|
|
4
|
+
|
|
5
|
+
// src/equator.ts
|
|
6
|
+
var DEG = Math.PI / 180;
|
|
7
|
+
var ARCSEC = DEG / 3600;
|
|
8
|
+
function toEquator(m, angle) {
|
|
9
|
+
const c = Math.cos(angle);
|
|
10
|
+
const s = Math.sin(angle);
|
|
11
|
+
return [
|
|
12
|
+
m[0],
|
|
13
|
+
m[1],
|
|
14
|
+
m[2],
|
|
15
|
+
c * m[3] - s * m[6],
|
|
16
|
+
c * m[4] - s * m[7],
|
|
17
|
+
c * m[5] - s * m[8],
|
|
18
|
+
s * m[3] + c * m[6],
|
|
19
|
+
s * m[4] + c * m[7],
|
|
20
|
+
s * m[5] + c * m[8]
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
function toTrueEquinox(m, dpsi) {
|
|
24
|
+
const c = Math.cos(dpsi);
|
|
25
|
+
const s = Math.sin(dpsi);
|
|
26
|
+
return [
|
|
27
|
+
c * m[0] - s * m[3],
|
|
28
|
+
c * m[1] - s * m[4],
|
|
29
|
+
c * m[2] - s * m[5],
|
|
30
|
+
s * m[0] + c * m[3],
|
|
31
|
+
s * m[1] + c * m[4],
|
|
32
|
+
s * m[2] + c * m[5],
|
|
33
|
+
m[6],
|
|
34
|
+
m[7],
|
|
35
|
+
m[8]
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
function eclipticRows(tt, kind) {
|
|
39
|
+
const frame = eclipticFrame(tt);
|
|
40
|
+
const m = frame.rows;
|
|
41
|
+
return kind === "mean" ? m : toTrueEquinox(m, frame.tilt.dpsi * ARCSEC);
|
|
42
|
+
}
|
|
43
|
+
function equatorRows(tt, kind) {
|
|
44
|
+
const frame = eclipticFrame(tt);
|
|
45
|
+
const { mobl, tobl, dpsi } = frame.tilt;
|
|
46
|
+
return kind === "mean" ? toEquator(frame.rows, mobl * DEG) : toEquator(toTrueEquinox(frame.rows, dpsi * ARCSEC), tobl * DEG);
|
|
47
|
+
}
|
|
48
|
+
function turn(m, x, y, z) {
|
|
49
|
+
return [m[0] * x + m[1] * y + m[2] * z, m[3] * x + m[4] * y + m[5] * z, m[6] * x + m[7] * y + m[8] * z];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
eclipticRows,
|
|
54
|
+
equatorRows,
|
|
55
|
+
turn
|
|
56
|
+
};
|