@zodiacs/engine 1.0.0 → 2.0.0-rc.2
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 +1244 -0
- package/LICENSING.md +172 -27
- package/NOTICE +78 -12
- package/README.md +344 -59
- package/dist/{api-WbxJ4Wj-.d.ts → api-C_SVd9BJ.d.ts} +39 -3
- package/dist/{ayanamsa--YQ46fET.d.ts → ayanamsa-Clgkekhh.d.ts} +2 -1
- package/dist/calc.d.ts +91 -4
- package/dist/calc.js +368 -126
- package/dist/chunk-CV53HA7R.js +87 -0
- package/dist/chunk-EEW7746S.js +83 -0
- package/dist/{chunk-WS3TDSP3.js → chunk-FVGA776A.js} +7 -3
- package/dist/chunk-HNVGWN3S.js +852 -0
- package/dist/chunk-I3L4POY7.js +18 -0
- package/dist/{chunk-FTX3JDJA.js → chunk-IXFUYEUF.js} +65 -29
- package/dist/{chunk-7TRLIFFI.js → chunk-LWZS7HI3.js} +1 -1
- package/dist/{chunk-CHSYDKBL.js → chunk-N4UQLCBN.js} +3 -3
- package/dist/{chunk-YIITY7Q7.js → chunk-NX4PHQBL.js} +34 -22
- package/dist/chunk-OVXQQEXL.js +41 -0
- package/dist/{chunk-SRXBTP5H.js → chunk-PNXIA7MI.js} +217 -192
- package/dist/chunk-RMBWKZI2.js +130 -0
- package/dist/{chunk-DMGHYCDI.js → chunk-SCRO6HWB.js} +5 -3
- package/dist/{chunk-OG4OYTJJ.js → chunk-T6F4FYYS.js} +1 -129
- package/dist/chunk-UXY4RU57.js +48 -0
- package/dist/{chunk-PFGUCNOK.js → chunk-WONTOC5W.js} +7 -6
- package/dist/conventions.d.ts +70 -0
- package/dist/conventions.js +26 -0
- package/dist/crossings.d.ts +15 -4
- package/dist/de440-pack.d.ts +43 -0
- package/dist/de440-pack.js +16 -0
- package/dist/de440.d.ts +113 -0
- package/dist/de440.js +19 -0
- package/dist/ephemeris-D1lM832F.d.ts +64 -0
- package/dist/geo.d.ts +28 -7
- package/dist/geo.js +2 -2
- package/dist/houses-extra.d.ts +5 -4
- package/dist/{houses-CFERsAlK.d.ts → houses-icK01yXi.d.ts} +3 -3
- package/dist/index.d.ts +8 -6
- package/dist/index.js +40 -28
- package/dist/{internal-math-DJJ8BYex.d.ts → internal-math-BGX23p4h.d.ts} +2 -2
- package/dist/internal-math.d.ts +4 -3
- package/dist/internal-math.js +14 -12
- package/dist/internal.d.ts +16 -7
- package/dist/internal.js +25 -4
- package/dist/lite-composite.js +114 -0
- package/dist/lite-declinations.js +253 -0
- package/dist/lite-dignities.js +333 -0
- package/dist/lite-sect.js +72 -0
- package/dist/lite.d.ts +82 -0
- package/dist/lite.js +4 -0
- package/dist/receipt.d.ts +3 -2
- package/dist/receipt.js +156 -67
- package/dist/{rulers-Dla6h_Sm.d.ts → rulers-CpS9qkvu.d.ts} +1 -1
- package/dist/sky.d.ts +4 -3
- package/dist/sky.js +17 -10
- package/dist/techniques.d.ts +102 -6
- package/dist/techniques.js +131 -56
- package/dist/time-bands-CZA9AlLg.d.ts +36 -0
- package/dist/time-scale-DIFNa0gz.d.ts +47 -0
- package/dist/time.d.ts +81 -0
- package/dist/time.js +74 -0
- package/dist/timing.d.ts +6 -5
- package/dist/timing.js +24 -17
- package/dist/types-BCnyWBQZ.d.ts +352 -0
- package/dist/vedic.d.ts +112 -4
- package/dist/vedic.js +369 -14
- package/dist/window.d.ts +22 -2
- package/dist/window.js +86 -28
- package/dist/{zone-history-ghdyO0Sc.d.ts → zone-history-0XzMGx9V.d.ts} +32 -10
- package/package.json +24 -3
- package/dist/types-B-yb_tGL.d.ts +0 -240
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/time-bands.ts
|
|
2
|
+
var isBand = (value) => typeof value === "number" && value >= 0 && value <= 1e10;
|
|
3
|
+
function timeBands(record) {
|
|
4
|
+
const { deltaT, timeScale } = Object(record);
|
|
5
|
+
const { input, basis, ut1MinusUtc } = Object(timeScale);
|
|
6
|
+
const d = deltaT?.sigma === null ? 0 : deltaT?.sigma;
|
|
7
|
+
const u = ut1MinusUtc === null ? 0 : ut1MinusUtc?.sigma;
|
|
8
|
+
if (!isBand(d) || !isBand(u) || !["utc", "ut1", "tt"].includes(input) || !["iers", "delta-t", "pinned"].includes(basis)) {
|
|
9
|
+
throw new RangeError("timeBands takes the deltaT and timeScale that a time basis, a chart or a calc instant records.");
|
|
10
|
+
}
|
|
11
|
+
if (input === "tt") return { tt: 0, ut1: d };
|
|
12
|
+
if (input === "ut1") return { tt: d, ut1: 0 };
|
|
13
|
+
return { tt: basis === "iers" ? 0 : basis === "pinned" ? u : Math.hypot(u, d), ut1: u };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
timeBands
|
|
18
|
+
};
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
dateFrom
|
|
3
|
-
} from "./chunk-CPALRSPC.js";
|
|
4
|
-
import {
|
|
5
|
-
findLongitudeCrossingsWith,
|
|
6
|
-
searchLongitudeCrossingsWith
|
|
7
|
-
} from "./chunk-TSS2SZWQ.js";
|
|
8
|
-
import {
|
|
9
|
-
assertDerivedFlags,
|
|
10
|
-
snapshotFlags,
|
|
11
|
-
timeFlags,
|
|
12
|
-
validateBirthSettings
|
|
13
|
-
} from "./chunk-PFGUCNOK.js";
|
|
14
1
|
import {
|
|
15
2
|
SPEED_STEP_DAYS,
|
|
16
3
|
bodyLongitude,
|
|
@@ -18,23 +5,43 @@ import {
|
|
|
18
5
|
computeChart,
|
|
19
6
|
computeChartDeclinations,
|
|
20
7
|
computePoints,
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
deltaTExtrapolated,
|
|
9
|
+
ephemerisAt,
|
|
10
|
+
longitudeSpeed,
|
|
11
|
+
notingFallbacks
|
|
12
|
+
} from "./chunk-PNXIA7MI.js";
|
|
13
|
+
import {
|
|
14
|
+
dateFrom
|
|
15
|
+
} from "./chunk-CPALRSPC.js";
|
|
16
|
+
import {
|
|
17
|
+
ASPECT_BODY_SET,
|
|
18
|
+
EPHEMERIS,
|
|
19
|
+
matchAspect
|
|
20
|
+
} from "./chunk-T6F4FYYS.js";
|
|
23
21
|
import {
|
|
24
22
|
TIME_SCALE_NAMES,
|
|
25
23
|
outsideReferenceSpan,
|
|
26
24
|
timeBasis
|
|
27
25
|
} from "./chunk-B5LKF437.js";
|
|
26
|
+
import {
|
|
27
|
+
findLongitudeCrossingsWith,
|
|
28
|
+
searchLongitudeCrossingsWith
|
|
29
|
+
} from "./chunk-TSS2SZWQ.js";
|
|
28
30
|
import {
|
|
29
31
|
POLAR_FALLBACK,
|
|
30
|
-
isPolarUndefinedHouseSystem
|
|
31
|
-
|
|
32
|
+
isPolarUndefinedHouseSystem,
|
|
33
|
+
meanObliquity
|
|
34
|
+
} from "./chunk-SCRO6HWB.js";
|
|
32
35
|
import {
|
|
33
|
-
ASPECT_BODY_SET,
|
|
34
|
-
matchAspect,
|
|
35
36
|
normalizeLongitude,
|
|
36
37
|
signForLongitude
|
|
37
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-RMBWKZI2.js";
|
|
39
|
+
import {
|
|
40
|
+
assertDerivedFlags,
|
|
41
|
+
snapshotFlags,
|
|
42
|
+
timeFlags,
|
|
43
|
+
validateBirthSettings
|
|
44
|
+
} from "./chunk-WONTOC5W.js";
|
|
38
45
|
|
|
39
46
|
// src/returns.ts
|
|
40
47
|
var DAY = 864e5;
|
|
@@ -51,7 +58,10 @@ function findLongitudeCrossings(body, targetLongitude, from, to, stepDays = 5) {
|
|
|
51
58
|
return findLongitudeCrossingsWith(bodyLongitude, body, targetLongitude, windowEnd(from, "start"), windowEnd(to, "end"), stepDays);
|
|
52
59
|
}
|
|
53
60
|
function searchLongitudeCrossings(body, targetLongitude, from, to, options) {
|
|
54
|
-
|
|
61
|
+
const { value, fallbacks } = notingFallbacks(
|
|
62
|
+
() => searchLongitudeCrossingsWith(bodyLongitude, body, targetLongitude, windowEnd(from, "start"), windowEnd(to, "end"), options)
|
|
63
|
+
);
|
|
64
|
+
return value.status === "complete" ? { ...value, flags: fallbacks } : value;
|
|
55
65
|
}
|
|
56
66
|
function groupIntoSeasons(crossings, gapDays = 400) {
|
|
57
67
|
if (!Number.isFinite(gapDays) || gapDays <= 0) {
|
|
@@ -198,7 +208,15 @@ function resolvedChart(source) {
|
|
|
198
208
|
if (isPolarUndefinedHouseSystem(input.houseSystem) && actualHouseSystem === POLAR_FALLBACK) {
|
|
199
209
|
expected.push("polar-fallback");
|
|
200
210
|
}
|
|
211
|
+
const basis = timeBasis(+input.utc, input.timeScale, input.deltaT);
|
|
212
|
+
if (hasHouses && resultFlags.values.includes("polar-angles") && Math.abs(input.latitude) >= 90 - meanObliquity(basis.ttDays / 36525) - 3e-3)
|
|
213
|
+
expected.push("polar-angles");
|
|
201
214
|
if (outsideReferenceSpan(input.utc)) expected.push("outside-reference-span");
|
|
215
|
+
if (resultFlags.values.length > expected.length && deltaTExtrapolated(basis, hasHouses))
|
|
216
|
+
expected.push("delta-t-extrapolated");
|
|
217
|
+
if (source.ephemeris === void 0 || source.ephemeris?.name === "astronomy-engine") {
|
|
218
|
+
for (const reason of ["de440-unavailable", "outside-de440-span"]) if (resultFlags.values.includes(reason)) expected.push(reason);
|
|
219
|
+
}
|
|
202
220
|
assertDerivedFlags(inputFlags?.values ?? [], expected);
|
|
203
221
|
if (resultFlags.values.length !== expected.length || !expected.every((flag) => resultFlags.values.includes(flag))) {
|
|
204
222
|
throw new RangeError("chart flags must agree with its input and supplied house result.");
|
|
@@ -226,6 +244,13 @@ var BIRTH_FIELDS = [
|
|
|
226
244
|
"flags",
|
|
227
245
|
"deltaT"
|
|
228
246
|
];
|
|
247
|
+
function noBareDate(value, name) {
|
|
248
|
+
if (typeof value === "string" && !value.includes("T")) {
|
|
249
|
+
throw new RangeError(
|
|
250
|
+
`${name} is a calendar date with no time. Give the birth instant with its UTC offset, such as 1990-05-03T08:30:00+02:00, or set timeKnown: false if the birth time is not known.`
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
229
254
|
function validateBirth(birth) {
|
|
230
255
|
if (!birth || typeof birth !== "object" || Array.isArray(birth)) {
|
|
231
256
|
throw new RangeError("birth must be an object containing a resolved utc instant.");
|
|
@@ -237,7 +262,8 @@ function validateBirth(birth) {
|
|
|
237
262
|
const settings = validateBirthSettings(birth);
|
|
238
263
|
const supplied = birth.flags;
|
|
239
264
|
const flags = supplied === void 0 ? void 0 : snapshotFlags(supplied);
|
|
240
|
-
const
|
|
265
|
+
const suppliedUtc = birth.utc;
|
|
266
|
+
const utc = dateFrom(suppliedUtc, "birth.utc");
|
|
241
267
|
const pin = birth.deltaT;
|
|
242
268
|
if (pin !== void 0 && (typeof pin !== "number" || !Number.isFinite(pin) || Math.abs(pin) > 1e10)) {
|
|
243
269
|
throw new RangeError("deltaT must be a finite number of seconds, at most 1e10 in size.");
|
|
@@ -246,13 +272,15 @@ function validateBirth(birth) {
|
|
|
246
272
|
if (scale !== void 0 && !TIME_SCALE_NAMES.includes(scale)) {
|
|
247
273
|
throw new RangeError('timeScale must be "utc", "ut1" or "tt".');
|
|
248
274
|
}
|
|
249
|
-
const possible = [];
|
|
275
|
+
const possible = ["delta-t-extrapolated", "de440-unavailable", "outside-de440-span"];
|
|
250
276
|
if (settings.timeKnown === false) possible.push("no-time");
|
|
251
|
-
else if (settings.
|
|
252
|
-
possible.push("polar-
|
|
277
|
+
else if (settings.latitude !== void 0) {
|
|
278
|
+
possible.push("polar-angles");
|
|
279
|
+
if (settings.houseSystem !== void 0 && isPolarUndefinedHouseSystem(settings.houseSystem)) possible.push("polar-fallback");
|
|
253
280
|
}
|
|
254
281
|
if (outsideReferenceSpan(utc)) possible.push("outside-reference-span");
|
|
255
282
|
assertDerivedFlags(flags?.values ?? [], possible);
|
|
283
|
+
if (settings.timeKnown !== false) noBareDate(suppliedUtc, "birth.utc");
|
|
256
284
|
const input = {
|
|
257
285
|
utc,
|
|
258
286
|
houseSystem: settings.houseSystem ?? "whole",
|
|
@@ -311,12 +339,15 @@ function phaseName(angle) {
|
|
|
311
339
|
function moonPhase(date) {
|
|
312
340
|
const at = dateFrom(date, "date");
|
|
313
341
|
const angle = normalizeLongitude(bodyLongitude("Moon", at) - bodyLongitude("Sun", at));
|
|
342
|
+
const { ephemeris, fallback } = ephemerisAt(at.getTime());
|
|
314
343
|
return {
|
|
315
344
|
at,
|
|
316
345
|
angle,
|
|
317
346
|
illumination: (1 - Math.cos(angle * Math.PI / 180)) / 2,
|
|
318
347
|
name: phaseName(angle),
|
|
319
|
-
waxing: angle < 180
|
|
348
|
+
waxing: angle < 180,
|
|
349
|
+
ephemeris: ephemeris.name,
|
|
350
|
+
...fallback !== null && { fallback }
|
|
320
351
|
};
|
|
321
352
|
}
|
|
322
353
|
function utcOf(input) {
|
|
@@ -331,10 +362,15 @@ function saturnReturn(birth) {
|
|
|
331
362
|
} else if (isBirth(birth)) {
|
|
332
363
|
const validated = validateBirth(birth);
|
|
333
364
|
utc = utcOf(
|
|
334
|
-
validated.flags?.values.
|
|
365
|
+
validated.flags?.values.some((flag) => flag === "polar-fallback" || flag === "polar-angles") ? computedBirth(validated).input : validated.input
|
|
335
366
|
);
|
|
336
|
-
} else
|
|
337
|
-
|
|
367
|
+
} else {
|
|
368
|
+
utc = dateFrom(birth, "birth");
|
|
369
|
+
}
|
|
370
|
+
const { value, fallbacks } = notingFallbacks(() => computeSaturnReturns(utc));
|
|
371
|
+
noBareDate(birth, "birth");
|
|
372
|
+
const ephemeris = fallbacks.length > 0 ? EPHEMERIS.name : ephemerisAt(utc.getTime()).ephemeris.name;
|
|
373
|
+
return { ...value, ephemeris, flags: fallbacks };
|
|
338
374
|
}
|
|
339
375
|
|
|
340
376
|
export {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-KFTJMMG7.js";
|
|
7
7
|
import {
|
|
8
8
|
validateBirthSettings
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-WONTOC5W.js";
|
|
10
10
|
|
|
11
11
|
// src/geo/calendar.ts
|
|
12
12
|
var GREGORIAN_ADOPTION_SOURCES = /* @__PURE__ */ Object.freeze({
|
|
@@ -48,14 +48,21 @@ var GREGORIAN_ADOPTION = /* @__PURE__ */ Object.freeze(
|
|
|
48
48
|
});
|
|
49
49
|
})
|
|
50
50
|
);
|
|
51
|
+
var ZONE_CITIES = "vienna - - prague berlin copenhagen madrid - paris london budapest rome - oslo - lisbon moscow -".split(" ");
|
|
52
|
+
function zoneAdoption(timeZone) {
|
|
53
|
+
return /^europe\/[a-z]/i.test(timeZone) ? GREGORIAN_ADOPTION[ZONE_CITIES.indexOf(timeZone.slice(7).toLowerCase())] : void 0;
|
|
54
|
+
}
|
|
51
55
|
function gregorianAdoption(country) {
|
|
52
56
|
return GREGORIAN_ADOPTION.find((row) => row.code === country || row.country === country);
|
|
53
57
|
}
|
|
54
58
|
function calendarNote(gregorianDate, calendar, country) {
|
|
55
59
|
if (!parseCalendarDate(gregorianDate, "gregorian")) throw new RangeError("gregorianDate must be a valid Gregorian date, YYYY-MM-DD.");
|
|
60
|
+
checkCalendarCountry(calendar, country);
|
|
61
|
+
return noteFor(gregorianDate, calendar, country);
|
|
62
|
+
}
|
|
63
|
+
function checkCalendarCountry(calendar, country) {
|
|
56
64
|
if (calendar !== "gregorian" && calendar !== "julian") throw new RangeError('calendar must be "gregorian" or "julian".');
|
|
57
65
|
if (typeof country !== "string" || !country.trim()) throw new RangeError("country must be a nonempty string.");
|
|
58
|
-
return noteFor(gregorianDate, calendar, country);
|
|
59
66
|
}
|
|
60
67
|
function noteFor(gregorianDate, calendar, country) {
|
|
61
68
|
const adoption = gregorianAdoption(country);
|
|
@@ -243,7 +250,7 @@ function firstChange(clockAt, lo, hi) {
|
|
|
243
250
|
}
|
|
244
251
|
return hi;
|
|
245
252
|
}
|
|
246
|
-
function readClock(wallMs, clockAt, samples) {
|
|
253
|
+
function readClock(wallMs, clockAt, samples, fold) {
|
|
247
254
|
const readings = [];
|
|
248
255
|
for (const offset of new Set(samples.map(clockAt))) {
|
|
249
256
|
const utcMs2 = wallMs - offset * 1e3;
|
|
@@ -253,7 +260,7 @@ function readClock(wallMs, clockAt, samples) {
|
|
|
253
260
|
}
|
|
254
261
|
const [first, second] = readings.sort((a, b) => a.utcMs - b.utcMs);
|
|
255
262
|
if (first) {
|
|
256
|
-
return second ? { chosen: first, kind: "fold", at: firstChange(clockAt, first.utcMs, second.utcMs) } : { chosen: first, kind: null, at: null };
|
|
263
|
+
return second ? { chosen: fold === "later" ? second : first, kind: "fold", at: firstChange(clockAt, first.utcMs, second.utcMs) } : { chosen: first, kind: null, at: null };
|
|
257
264
|
}
|
|
258
265
|
let lo = wallMs - PROBE - DAY;
|
|
259
266
|
let hi = wallMs + PROBE + DAY;
|
|
@@ -290,28 +297,25 @@ function birthplaceClock(history, wallMs, longitude, zoneAt) {
|
|
|
290
297
|
lineEnds: era.slice(0, -1).map(([until]) => until)
|
|
291
298
|
};
|
|
292
299
|
}
|
|
293
|
-
function readOptions(options) {
|
|
294
|
-
if (options === void 0) return { calendar: "gregorian" };
|
|
300
|
+
function readOptions(options = {}) {
|
|
295
301
|
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
296
302
|
throw new RangeError("options must be an object.");
|
|
297
303
|
}
|
|
298
304
|
for (const key of Object.getOwnPropertyNames(options)) {
|
|
299
|
-
if (!["longitude", "calendar", "country"].includes(key)) throw new RangeError(`Unknown local time option "${key}".`);
|
|
305
|
+
if (!["longitude", "calendar", "country", "fold"].includes(key)) throw new RangeError(`Unknown local time option "${key}".`);
|
|
300
306
|
}
|
|
301
|
-
const { longitude, calendar = "gregorian", country } = options;
|
|
307
|
+
const { longitude, calendar = "gregorian", country, fold = "earlier" } = options;
|
|
302
308
|
if (longitude !== void 0 && !(typeof longitude === "number" && Math.abs(longitude) <= 180)) {
|
|
303
309
|
throw new RangeError("longitude must be between -180 and 180 degrees.");
|
|
304
310
|
}
|
|
305
|
-
|
|
306
|
-
if (
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
return { longitude, calendar, country };
|
|
311
|
+
checkCalendarCountry(calendar, country === void 0 ? "-" : country);
|
|
312
|
+
if (fold !== "earlier" && fold !== "later") throw new RangeError('fold must be "earlier" or "later".');
|
|
313
|
+
return { longitude, calendar, country, fold };
|
|
310
314
|
}
|
|
311
315
|
var pad = (value, width = 2) => String(value).padStart(width, "0");
|
|
312
316
|
function resolveLocalToUtc(date, time, timeZone, options) {
|
|
313
317
|
offsetFormatter(timeZone);
|
|
314
|
-
const { longitude, calendar, country } = readOptions(options);
|
|
318
|
+
const { longitude, calendar, country, fold } = readOptions(options);
|
|
315
319
|
const written = parseCalendarDate(date, calendar);
|
|
316
320
|
const hhmm = typeof time === "string" ? /^([01]\d|2[0-3]):([0-5]\d)$/u.exec(time) : null;
|
|
317
321
|
if (!written || !hhmm) {
|
|
@@ -330,8 +334,8 @@ function resolveLocalToUtc(date, time, timeZone, options) {
|
|
|
330
334
|
const place = longitude !== void 0 && history ? birthplaceClock(history, wallMs, longitude, zoneAt) : null;
|
|
331
335
|
const samples = [wallMs - PROBE, wallMs, wallMs + PROBE, ...place ? [place.endMs - 1, place.endMs, place.legalFrom] : []];
|
|
332
336
|
const clockAt = place ? place.clockAt : zoneAt;
|
|
333
|
-
const zoneReading = readClock(wallMs, zoneAt, samples);
|
|
334
|
-
const reading = place ? readClock(wallMs, clockAt, samples) : zoneReading;
|
|
337
|
+
const zoneReading = readClock(wallMs, zoneAt, samples, fold);
|
|
338
|
+
const reading = place ? readClock(wallMs, clockAt, samples, fold) : zoneReading;
|
|
335
339
|
const { chosen, kind } = reading;
|
|
336
340
|
const inEra = !!place && chosen.utcMs < place.endMs;
|
|
337
341
|
const count = history && chosen.utcMs < 0 ? typeIndexAt(history, chosen.utcMs) : -1;
|
|
@@ -358,8 +362,14 @@ function resolveLocalToUtc(date, time, timeZone, options) {
|
|
|
358
362
|
};
|
|
359
363
|
}
|
|
360
364
|
const lmt = inEra || !place && history?.zoneEraEnd != null && chosen.utcMs < history.zoneEraEnd;
|
|
361
|
-
const flags = kind ? [kind
|
|
365
|
+
const flags = kind ? [`dst-${kind}`] : [];
|
|
362
366
|
if (lmt) flags.push("lmt");
|
|
367
|
+
if (!(country && gregorianAdoption(country))) {
|
|
368
|
+
const own = zoneAdoption(timeZone);
|
|
369
|
+
const near = /^(europe|asia|etc)\/|^[^/]+$/i.test(timeZone);
|
|
370
|
+
if ((own ? [own] : GREGORIAN_ADOPTION).some((r) => date > r.lastJulian && date < r.firstGregorian && (near || r.firstGregorian < "1800")))
|
|
371
|
+
flags.push("calendar-unknown");
|
|
372
|
+
}
|
|
363
373
|
const localMeanTime = longitude !== void 0 && place && (inEra || kind === "gap" && reading.at === place.endMs) ? { longitude, zoneOffsetMinutes: zoneReading.chosen.offset / 60 } : null;
|
|
364
374
|
const zone = shipped ? {
|
|
365
375
|
source: "tzdb",
|
|
@@ -388,7 +398,7 @@ function resolveLocalToUtc(date, time, timeZone, options) {
|
|
|
388
398
|
timeZone,
|
|
389
399
|
offsetMinutes,
|
|
390
400
|
gapShiftMinutes: kind === "gap" && transition ? transition.offsetAfterMinutes - transition.offsetBeforeMinutes : 0,
|
|
391
|
-
policy: { fold: "earlier", gap: "shift-forward" },
|
|
401
|
+
policy: { fold: kind === "fold" ? fold : "earlier", gap: "shift-forward" },
|
|
392
402
|
calendar,
|
|
393
403
|
writtenDate: date,
|
|
394
404
|
tzdbVersion: zone.tzdbVersion,
|
|
@@ -430,7 +440,8 @@ var LOCAL_BIRTH_KEYS = [
|
|
|
430
440
|
"houseSystem",
|
|
431
441
|
"timeKnown",
|
|
432
442
|
"calendar",
|
|
433
|
-
"country"
|
|
443
|
+
"country",
|
|
444
|
+
"fold"
|
|
434
445
|
];
|
|
435
446
|
function resolveLocalBirth(input) {
|
|
436
447
|
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
@@ -441,15 +452,16 @@ function resolveLocalBirth(input) {
|
|
|
441
452
|
}
|
|
442
453
|
const fields = Object.fromEntries(LOCAL_BIRTH_KEYS.map((key) => [key, input[key]]));
|
|
443
454
|
const settings = validateBirthSettings(fields);
|
|
444
|
-
const time = fields
|
|
455
|
+
const { time, calendar, country, fold } = fields;
|
|
445
456
|
const timeKnown = settings.timeKnown ?? time !== void 0;
|
|
446
457
|
if (timeKnown && time === void 0) {
|
|
447
458
|
throw new RangeError("time is required when timeKnown is true.");
|
|
448
459
|
}
|
|
449
460
|
const resolution = resolveLocalToUtc(fields.date, time === void 0 ? "12:00" : time, fields.timeZone, {
|
|
450
461
|
longitude: settings.longitude,
|
|
451
|
-
calendar
|
|
452
|
-
country
|
|
462
|
+
calendar,
|
|
463
|
+
country,
|
|
464
|
+
fold
|
|
453
465
|
});
|
|
454
466
|
return {
|
|
455
467
|
birth: {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/convention-ids.ts
|
|
2
|
+
var NAMESPACE = /^[A-Za-z][A-Za-z0-9-]*$/u;
|
|
3
|
+
var VALUE = /^[^\s\p{Cc}\p{Cf}\p{Cs}]+$/u;
|
|
4
|
+
function conventionId(namespace, value) {
|
|
5
|
+
if (typeof namespace !== "string" || !NAMESPACE.test(namespace))
|
|
6
|
+
throw new RangeError("A convention namespace is a letter, then letters, digits or hyphens.");
|
|
7
|
+
if (typeof value !== "string" || !VALUE.test(value))
|
|
8
|
+
throw new RangeError("A convention value is not empty and has no white space, control character or lone surrogate.");
|
|
9
|
+
return `${namespace}:${value}`;
|
|
10
|
+
}
|
|
11
|
+
function natalConventionIds(envelope) {
|
|
12
|
+
const { receipt, result } = envelope;
|
|
13
|
+
const ids = /* @__PURE__ */ new Set();
|
|
14
|
+
for (const fields of [receipt.conventions, receipt.coverage])
|
|
15
|
+
for (const [key, value] of Object.entries(fields)) ids.add(conventionId(key, value));
|
|
16
|
+
const { requested, actual, absenceReason } = receipt.houses;
|
|
17
|
+
for (const system of [requested, actual]) if (system !== null) ids.add(conventionId("house", system));
|
|
18
|
+
if (absenceReason !== null) ids.add(conventionId("house-absence", absenceReason));
|
|
19
|
+
for (const flag of [...receipt.inputFlags, ...receipt.resultFlags]) ids.add(conventionId("flag", flag));
|
|
20
|
+
ids.add(conventionId("reference", receipt.reference));
|
|
21
|
+
if (receipt.timeScale !== void 0) ids.add(conventionId("time-scale", receipt.timeScale));
|
|
22
|
+
const ephemeris = receipt.engine.ephemeris;
|
|
23
|
+
if (ephemeris !== void 0)
|
|
24
|
+
ids.add(conventionId("ephemeris", `${ephemeris.name}@${ephemeris.version}`));
|
|
25
|
+
if (result.deltaT !== void 0) {
|
|
26
|
+
ids.add(conventionId("deltat-model", result.deltaT.model));
|
|
27
|
+
ids.add(conventionId("deltat-segment", result.deltaT.segment));
|
|
28
|
+
}
|
|
29
|
+
if (result.timeScale !== void 0) {
|
|
30
|
+
ids.add(conventionId("time-scale", result.timeScale.input));
|
|
31
|
+
ids.add(conventionId("time-basis", result.timeScale.basis));
|
|
32
|
+
if (result.timeScale.ut1MinusUtc !== null)
|
|
33
|
+
ids.add(conventionId("ut1-source", result.timeScale.ut1MinusUtc.source));
|
|
34
|
+
}
|
|
35
|
+
return [...ids].sort();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
conventionId,
|
|
40
|
+
natalConventionIds
|
|
41
|
+
};
|