@zodiacs/engine 0.1.1-rc.14 → 0.1.1-rc.15
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 +364 -6
- package/LICENSING.md +180 -14
- package/NOTICE +73 -9
- package/README.md +116 -69
- package/dist/api-CoB_kqE3.d.ts +198 -0
- package/dist/chunk-CWI4YUDL.js +355 -0
- package/dist/chunk-KFTJMMG7.js +61 -0
- package/dist/chunk-KHBLFXFG.js +227 -0
- package/dist/{chunk-NAJ735VN.js → chunk-MFF3VKO3.js} +1 -1
- package/dist/chunk-OYGRVGXD.js +25 -0
- package/dist/{chunk-4OSOCZY2.js → chunk-ZHVI3KWJ.js} +21 -6
- package/dist/{chunk-RETEVD4F.js → chunk-ZZPITHQS.js} +115 -110
- 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 +414 -109
- package/dist/index.d.ts +7 -201
- package/dist/index.js +28 -305
- package/dist/{internal-math-BE2hcSHd.d.ts → internal-math-BbktkHCc.d.ts} +14 -1
- package/dist/internal-math.d.ts +2 -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 +56 -36
- package/dist/receipt.js +188 -33
- package/dist/timing.d.ts +414 -0
- package/dist/timing.js +851 -0
- package/dist/{types-CeafogFp.d.ts → types-BsWaqwU_.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 +394 -0
- package/dist/vedic.js +947 -0
- package/package.json +11 -3
- package/dist/chunk-GFT24GFR.js +0 -25
package/dist/internal.js
CHANGED
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
computeBodies,
|
|
4
4
|
computeChart,
|
|
5
5
|
longitudeSpeed
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-ZZPITHQS.js";
|
|
7
|
+
import "./chunk-ZHVI3KWJ.js";
|
|
8
|
+
import "./chunk-KHBLFXFG.js";
|
|
9
9
|
import "./chunk-ONBZ4HK7.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-MFF3VKO3.js";
|
|
11
11
|
export {
|
|
12
12
|
bodyLongitude,
|
|
13
13
|
computeBodies,
|
package/dist/receipt.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HouseSystem, c as ChartFlag, b as Chart, d as BirthInput } from './types-
|
|
1
|
+
import { T as TimeScaleName, H as HouseSystem, c as ChartFlag, b as Chart, d as BirthInput } from './types-BsWaqwU_.js';
|
|
2
2
|
import './deltat.js';
|
|
3
3
|
|
|
4
4
|
/** Zodiacs-owned draft vocabulary; not an industry interoperability standard. */
|
|
@@ -20,19 +20,43 @@ interface NatalJsonObject {
|
|
|
20
20
|
[key: string]: NatalJsonValue;
|
|
21
21
|
}
|
|
22
22
|
type NatalReference = "supplied-instant" | "utc-noon" | "local-noon";
|
|
23
|
-
/**
|
|
23
|
+
/** A clock change a local resolution records. */
|
|
24
|
+
interface NatalZoneTransition {
|
|
25
|
+
at: string;
|
|
26
|
+
offsetBeforeMinutes: number;
|
|
27
|
+
offsetAfterMinutes: number;
|
|
28
|
+
cause: "dst" | "legal-change" | "date-line";
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Captured assertions, checked arithmetically without consulting today's
|
|
32
|
+
* Intl/tzdb. The fields after `policy` are optional from the time-basis
|
|
33
|
+
* conventions set on, so a record in rc.14's shape is accepted, and absent
|
|
34
|
+
* before it; each one given is checked. `resolveLocalToUtc` returns the whole
|
|
35
|
+
* object as `localResolution` (docs/time.md).
|
|
36
|
+
*/
|
|
24
37
|
interface NatalLocalResolution {
|
|
38
|
+
/** The proleptic Gregorian date resolved. */
|
|
25
39
|
date: string;
|
|
26
40
|
time: string;
|
|
27
41
|
timeZone: string;
|
|
28
|
-
/** Offset at the resolved instant, minutes east of UTC;
|
|
42
|
+
/** Offset at the resolved instant, minutes east of UTC; may be fractional. */
|
|
29
43
|
offsetMinutes: number;
|
|
30
|
-
/** Forward wall-clock shift; positive only for a reported
|
|
44
|
+
/** Forward wall-clock shift; positive only for a reported gap. */
|
|
31
45
|
gapShiftMinutes: number;
|
|
32
46
|
policy: {
|
|
33
47
|
fold: "earlier";
|
|
34
48
|
gap: "shift-forward";
|
|
35
49
|
};
|
|
50
|
+
calendar?: "gregorian" | "julian";
|
|
51
|
+
writtenDate?: string;
|
|
52
|
+
tzdbVersion?: string | null;
|
|
53
|
+
dataForm?: "main+backzone" | "main" | "host";
|
|
54
|
+
clock?: "local-mean-time" | "legal";
|
|
55
|
+
transition?: NatalZoneTransition | null;
|
|
56
|
+
localMeanTime?: {
|
|
57
|
+
longitude: number;
|
|
58
|
+
zoneOffsetMinutes: number;
|
|
59
|
+
} | null;
|
|
36
60
|
}
|
|
37
61
|
/** Supplied facts are claims, including hashes. This codec authenticates none of them. */
|
|
38
62
|
interface NatalProvenanceClaims {
|
|
@@ -92,11 +116,12 @@ declare const CONVENTIONS_RC7: Readonly<{
|
|
|
92
116
|
readonly longitudeUnit: "degrees-[0,360)";
|
|
93
117
|
}>;
|
|
94
118
|
/**
|
|
95
|
-
* The conventions
|
|
96
|
-
* time and aberration but not for gravitational
|
|
97
|
-
* series
|
|
119
|
+
* The conventions engine versions 0.1.1-rc.8 to rc.14 recorded: the planets
|
|
120
|
+
* corrected for light time and aberration but not for gravitational
|
|
121
|
+
* deflection, the Moon's series for neither, and the instant read as UT1.
|
|
122
|
+
* Their receipts stay readable.
|
|
98
123
|
*/
|
|
99
|
-
declare const
|
|
124
|
+
declare const CONVENTIONS_RC8: Readonly<{
|
|
100
125
|
readonly planetPositions: "aberrated-geocentric-ecliptic-of-date;no-deflection";
|
|
101
126
|
readonly moonPosition: "astronomy-engine-ecliptic-geo-moon;no-light-time;no-aberration";
|
|
102
127
|
readonly deltaT: "tt-minus-ut1;ut1-read-as-utc;value-in-result";
|
|
@@ -108,12 +133,17 @@ declare const CONVENTIONS: Readonly<{
|
|
|
108
133
|
readonly moonNodes: "instantaneous-geocentric-moon-orbit-plane";
|
|
109
134
|
readonly longitudeUnit: "degrees-[0,360)";
|
|
110
135
|
}>;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
136
|
+
/**
|
|
137
|
+
* The conventions this engine records: the rc.8 set, with the time basis in
|
|
138
|
+
* the result (`result.timeScale`, docs/time.md) and local times resolved on
|
|
139
|
+
* the shipped tzdb history before 1970, their flags from its records.
|
|
140
|
+
*/
|
|
141
|
+
declare const CONVENTIONS: Readonly<{
|
|
142
|
+
readonly deltaT: "tt-minus-ut1;value-in-result";
|
|
143
|
+
readonly timeScale: "tt-from-leap-seconds-and-ut1-from-iers-1972-to-table-end;delta-t-model-otherwise;in-result";
|
|
144
|
+
readonly localTime: "tzdb-shards-before-1970;host-intl-from-1970;flags-from-transition-record";
|
|
114
145
|
readonly planetPositions: "aberrated-geocentric-ecliptic-of-date;no-deflection";
|
|
115
146
|
readonly moonPosition: "astronomy-engine-ecliptic-geo-moon;no-light-time;no-aberration";
|
|
116
|
-
readonly deltaT: "tt-minus-ut1;ut1-read-as-utc;value-in-result";
|
|
117
147
|
readonly angles: "gast-and-true-obliquity";
|
|
118
148
|
readonly speed: "degrees-per-day;central-difference-plus-minus-0.001-day;nodes-plus-minus-0.25-day";
|
|
119
149
|
readonly aspects: "major-aspects;sun-moon-eight-planets;no-nodes;applying-instantaneous-orb-rate";
|
|
@@ -121,27 +151,15 @@ declare const NATAL_RECEIPT_CONVENTION_SETS: readonly [Readonly<{
|
|
|
121
151
|
readonly zodiac: "tropical";
|
|
122
152
|
readonly moonNodes: "instantaneous-geocentric-moon-orbit-plane";
|
|
123
153
|
readonly longitudeUnit: "degrees-[0,360)";
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
readonly longitudeUnit: "degrees-[0,360)";
|
|
134
|
-
}>, Readonly<{
|
|
135
|
-
readonly calendar: "proleptic-gregorian";
|
|
136
|
-
readonly zodiac: "tropical";
|
|
137
|
-
readonly planetPositions: "apparent-geocentric-ecliptic-of-date";
|
|
138
|
-
readonly moonPosition: "astronomy-engine-ecliptic-geo-moon";
|
|
139
|
-
readonly moonNodes: "instantaneous-geocentric-moon-orbit-plane";
|
|
140
|
-
readonly angles: "gast-and-mean-obliquity";
|
|
141
|
-
readonly longitudeUnit: "degrees-[0,360)";
|
|
142
|
-
readonly speed: "degrees-per-day;central-difference-plus-minus-0.25-day";
|
|
143
|
-
readonly aspects: "major-aspects;sun-moon-eight-planets;no-nodes";
|
|
144
|
-
}>];
|
|
154
|
+
}>;
|
|
155
|
+
type ConventionSet = typeof CONVENTIONS | typeof CONVENTIONS_RC8 | typeof CONVENTIONS_RC7 | typeof CONVENTIONS_RC3;
|
|
156
|
+
/** Every conventions set a receipt may carry, the current one first. */
|
|
157
|
+
declare const NATAL_RECEIPT_CONVENTION_SETS: readonly [
|
|
158
|
+
typeof CONVENTIONS,
|
|
159
|
+
typeof CONVENTIONS_RC8,
|
|
160
|
+
typeof CONVENTIONS_RC7,
|
|
161
|
+
typeof CONVENTIONS_RC3
|
|
162
|
+
];
|
|
145
163
|
declare const COVERAGE: Readonly<{
|
|
146
164
|
readonly assessment: "finite-reference-cases-only";
|
|
147
165
|
readonly broadDateRange: "not-certified";
|
|
@@ -150,7 +168,9 @@ declare const COVERAGE: Readonly<{
|
|
|
150
168
|
}>;
|
|
151
169
|
interface NatalReceipt {
|
|
152
170
|
schema: typeof NATAL_RECEIPT_SCHEMA;
|
|
171
|
+
/** On the scale `timeScale` names; UTC before the time-basis set. */
|
|
153
172
|
instant: string;
|
|
173
|
+
timeScale?: TimeScaleName;
|
|
154
174
|
sourceInstant: string | null;
|
|
155
175
|
/** Caller declaration, not verification of a human birth time's precision. */
|
|
156
176
|
timeKnown: boolean;
|
|
@@ -188,8 +208,8 @@ interface NatalEnvelope {
|
|
|
188
208
|
/** This draft implements no optional required features; unknown ones fail closed. */
|
|
189
209
|
requiredFeatures: string[];
|
|
190
210
|
receipt: NatalReceipt;
|
|
191
|
-
/** `deltaT`
|
|
192
|
-
result: Pick<Chart, "bodies" | "angles" | "houses" | "aspects"> & Partial<Pick<Chart, "deltaT">>;
|
|
211
|
+
/** `deltaT` from the rc.8 set on, `timeScale` from the time-basis set on. */
|
|
212
|
+
result: Pick<Chart, "bodies" | "angles" | "houses" | "aspects"> & Partial<Pick<Chart, "deltaT" | "timeScale">>;
|
|
193
213
|
extensions?: NatalJsonObject;
|
|
194
214
|
}
|
|
195
215
|
type NatalEnvelopeParseResult = {
|
|
@@ -221,4 +241,4 @@ declare function natalReplayInput(envelope: NatalEnvelope): BirthInput;
|
|
|
221
241
|
/** A fresh fixed allowlist: no claimed identifiers, versions, hashes, or input/result values. */
|
|
222
242
|
declare function redactNatalEnvelope(envelope: NatalEnvelope): NatalDiagnostic;
|
|
223
243
|
|
|
224
|
-
export { NATAL_DIAGNOSTIC_SCHEMA, NATAL_ENVELOPE_LIMITS, NATAL_ENVELOPE_SCHEMA, NATAL_RECEIPT_CONVENTION_SETS, NATAL_RECEIPT_SCHEMA, type NatalDiagnostic, type NatalEnvelope, type NatalEnvelopeContext, NatalEnvelopeError, type NatalEnvelopeErrorCode, type NatalEnvelopeParseResult, type NatalJsonObject, type NatalJsonValue, type NatalLocalResolution, type NatalProvenanceClaims, type NatalReceipt, type NatalReference, createNatalEnvelope, natalReplayInput, parseNatalEnvelope, redactNatalEnvelope, serializeNatalEnvelope };
|
|
244
|
+
export { NATAL_DIAGNOSTIC_SCHEMA, NATAL_ENVELOPE_LIMITS, NATAL_ENVELOPE_SCHEMA, NATAL_RECEIPT_CONVENTION_SETS, NATAL_RECEIPT_SCHEMA, type NatalDiagnostic, type NatalEnvelope, type NatalEnvelopeContext, NatalEnvelopeError, type NatalEnvelopeErrorCode, type NatalEnvelopeParseResult, type NatalJsonObject, type NatalJsonValue, type NatalLocalResolution, type NatalProvenanceClaims, type NatalReceipt, type NatalReference, type NatalZoneTransition, createNatalEnvelope, natalReplayInput, parseNatalEnvelope, redactNatalEnvelope, serializeNatalEnvelope };
|
package/dist/receipt.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
julianToGregorian,
|
|
3
|
+
parseCalendarDate
|
|
4
|
+
} from "./chunk-KFTJMMG7.js";
|
|
1
5
|
import {
|
|
2
6
|
dateFrom
|
|
3
7
|
} from "./chunk-CPALRSPC.js";
|
|
4
8
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
DELTA_T_IERS_MODEL,
|
|
10
|
+
TIME_SCALE_NAMES,
|
|
11
|
+
UT1_DATA,
|
|
12
|
+
outsideReferenceSpan,
|
|
13
|
+
timeBasis
|
|
14
|
+
} from "./chunk-KHBLFXFG.js";
|
|
7
15
|
import {
|
|
8
16
|
DELTA_T_MODEL,
|
|
9
17
|
DELTA_T_TABLE,
|
|
@@ -16,7 +24,7 @@ import {
|
|
|
16
24
|
EPHEMERIS,
|
|
17
25
|
SIGNS,
|
|
18
26
|
aspectMotion
|
|
19
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-MFF3VKO3.js";
|
|
20
28
|
|
|
21
29
|
// src/receipt-json.ts
|
|
22
30
|
function parseReceiptJson(json, limits) {
|
|
@@ -117,6 +125,36 @@ function parseReceiptJson(json, limits) {
|
|
|
117
125
|
}
|
|
118
126
|
}
|
|
119
127
|
|
|
128
|
+
// src/semver.ts
|
|
129
|
+
var SEMVER = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
|
|
130
|
+
var DIGITS = /^\d+$/;
|
|
131
|
+
function isVersion(value) {
|
|
132
|
+
return SEMVER.test(value);
|
|
133
|
+
}
|
|
134
|
+
function compareNumbers(a, b) {
|
|
135
|
+
if (a.length !== b.length) return a.length < b.length ? -1 : 1;
|
|
136
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
137
|
+
}
|
|
138
|
+
function compareVersions(a, b) {
|
|
139
|
+
const x = SEMVER.exec(a);
|
|
140
|
+
const y = SEMVER.exec(b);
|
|
141
|
+
if (!x || !y) throw new RangeError("compareVersions takes SemVer 2.0.0 versions.");
|
|
142
|
+
for (let part = 1; part <= 3; part += 1) {
|
|
143
|
+
const order = compareNumbers(x[part], y[part]);
|
|
144
|
+
if (order !== 0) return order;
|
|
145
|
+
}
|
|
146
|
+
if (x[4] === void 0 || y[4] === void 0) return x[4] === y[4] ? 0 : x[4] === void 0 ? 1 : -1;
|
|
147
|
+
const p = x[4].split(".");
|
|
148
|
+
const q = y[4].split(".");
|
|
149
|
+
for (let k = 0; k < p.length && k < q.length; k += 1) {
|
|
150
|
+
const numeric = DIGITS.test(p[k]);
|
|
151
|
+
if (numeric !== DIGITS.test(q[k])) return numeric ? -1 : 1;
|
|
152
|
+
const order = numeric ? compareNumbers(p[k], q[k]) : p[k] < q[k] ? -1 : p[k] > q[k] ? 1 : 0;
|
|
153
|
+
if (order !== 0) return order;
|
|
154
|
+
}
|
|
155
|
+
return p.length === q.length ? 0 : p.length < q.length ? -1 : 1;
|
|
156
|
+
}
|
|
157
|
+
|
|
120
158
|
// src/receipt.ts
|
|
121
159
|
var NATAL_ENVELOPE_SCHEMA = "zodiacs.natal-envelope.draft-v1";
|
|
122
160
|
var NATAL_RECEIPT_SCHEMA = "zodiacs.calculation-receipt.draft-v1";
|
|
@@ -161,22 +199,26 @@ var CONVENTIONS_RC7 = Object.freeze({
|
|
|
161
199
|
speed: "degrees-per-day;central-difference-plus-minus-0.001-day;nodes-plus-minus-0.25-day",
|
|
162
200
|
aspects: "major-aspects;sun-moon-eight-planets;no-nodes;applying-instantaneous-orb-rate"
|
|
163
201
|
});
|
|
164
|
-
var
|
|
202
|
+
var CONVENTIONS_RC8 = Object.freeze({
|
|
165
203
|
...CONVENTIONS_RC7,
|
|
166
204
|
planetPositions: "aberrated-geocentric-ecliptic-of-date;no-deflection",
|
|
167
205
|
moonPosition: "astronomy-engine-ecliptic-geo-moon;no-light-time;no-aberration",
|
|
168
206
|
deltaT: "tt-minus-ut1;ut1-read-as-utc;value-in-result"
|
|
169
207
|
});
|
|
170
|
-
var
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
208
|
+
var CONVENTIONS = Object.freeze({
|
|
209
|
+
...CONVENTIONS_RC8,
|
|
210
|
+
deltaT: "tt-minus-ut1;value-in-result",
|
|
211
|
+
timeScale: "tt-from-leap-seconds-and-ut1-from-iers-1972-to-table-end;delta-t-model-otherwise;in-result",
|
|
212
|
+
localTime: "tzdb-shards-before-1970;host-intl-from-1970;flags-from-transition-record"
|
|
213
|
+
});
|
|
214
|
+
var NATAL_RECEIPT_CONVENTION_SETS = Object.freeze([CONVENTIONS, CONVENTIONS_RC8, CONVENTIONS_RC7, CONVENTIONS_RC3]);
|
|
175
215
|
var RC3_TO_RC6 = /^0\.1\.1-rc\.[3-6](?:\+[A-Za-z0-9.-]+)?$/;
|
|
176
216
|
var RC7 = /^0\.1\.1-rc\.7(?:\+[A-Za-z0-9.-]+)?$/;
|
|
177
|
-
var
|
|
178
|
-
var
|
|
179
|
-
var
|
|
217
|
+
var RC8_TO_RC14 = /^0\.1\.1-rc\.(?:[89]|1[0-4])(?:\+[A-Za-z0-9.-]+)?$/;
|
|
218
|
+
var before = (version2, release) => compareVersions(version2, release) < 0;
|
|
219
|
+
var TIME_BASIS_RELEASE = "0.1.1-rc.15";
|
|
220
|
+
var RC9_RELEASE = "0.1.1-rc.9";
|
|
221
|
+
var RC10_RELEASE = "0.1.1-rc.10";
|
|
180
222
|
var COVERAGE = Object.freeze({
|
|
181
223
|
assessment: "finite-reference-cases-only",
|
|
182
224
|
broadDateRange: "not-certified",
|
|
@@ -323,8 +365,7 @@ function text(value, maximum = 128) {
|
|
|
323
365
|
}
|
|
324
366
|
function version(value) {
|
|
325
367
|
const parsed = text(value, 64);
|
|
326
|
-
if (
|
|
327
|
-
fail("invalid_value");
|
|
368
|
+
if (!isVersion(parsed)) fail("invalid_value");
|
|
328
369
|
return parsed;
|
|
329
370
|
}
|
|
330
371
|
function canonicalInstant(value) {
|
|
@@ -381,32 +422,77 @@ var DELTA_T_SEGMENTS = [
|
|
|
381
422
|
"extrapolated"
|
|
382
423
|
];
|
|
383
424
|
var J2000_MS = Date.UTC(2e3, 0, 1, 12);
|
|
384
|
-
|
|
425
|
+
var IERS_SEGMENTS = ["observed", "predicted", "fallback"];
|
|
426
|
+
function validateDeltaT(value, instant, timeBasis2) {
|
|
385
427
|
const deltaT = record(value);
|
|
386
428
|
fields(deltaT, ["seconds", "sigma", "model", "table", "tableDigest", "segment"]);
|
|
387
429
|
const seconds = number(deltaT.seconds, -1e10, 1e10);
|
|
388
430
|
if (deltaT.model === "pinned") {
|
|
389
431
|
if (deltaT.sigma !== null || deltaT.table !== null || deltaT.tableDigest !== null || deltaT.segment !== "pinned")
|
|
390
432
|
fail("inconsistent_result");
|
|
391
|
-
return;
|
|
433
|
+
return deltaT;
|
|
392
434
|
}
|
|
393
|
-
|
|
435
|
+
const iers = timeBasis2 && deltaT.model === DELTA_T_IERS_MODEL;
|
|
436
|
+
if (!iers && deltaT.model !== DELTA_T_MODEL) fail("unsupported_feature");
|
|
394
437
|
number(deltaT.sigma, 0, 1e10);
|
|
395
438
|
if (typeof deltaT.table !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(deltaT.table))
|
|
396
439
|
fail("invalid_value");
|
|
397
440
|
if (typeof deltaT.tableDigest !== "string" || !/^[a-f0-9]{16}$/.test(deltaT.tableDigest))
|
|
398
441
|
fail("invalid_value");
|
|
399
|
-
const segment = choice(deltaT.segment, DELTA_T_SEGMENTS);
|
|
400
|
-
if (deltaT.tableDigest === DELTA_T_TABLE.digest) {
|
|
442
|
+
const segment = choice(deltaT.segment, iers ? IERS_SEGMENTS : DELTA_T_SEGMENTS);
|
|
443
|
+
if (!timeBasis2 && deltaT.tableDigest === DELTA_T_TABLE.digest) {
|
|
401
444
|
const expected = deltaTAt((Date.parse(instant) - J2000_MS) / 864e5);
|
|
402
445
|
if (deltaT.table !== expected.table || segment !== expected.segment || Math.abs(seconds - expected.seconds) > 1e-9 || Math.abs(deltaT.sigma - expected.sigma) > 1e-9)
|
|
403
446
|
fail("inconsistent_result");
|
|
404
447
|
}
|
|
448
|
+
return deltaT;
|
|
449
|
+
}
|
|
450
|
+
function same(actual, expected) {
|
|
451
|
+
if (typeof expected === "number") return typeof actual === "number" && Math.abs(actual - expected) <= 1e-9;
|
|
452
|
+
if (!expected || typeof expected !== "object") return actual === expected;
|
|
453
|
+
const keys = Object.keys(expected);
|
|
454
|
+
return !!actual && typeof actual === "object" && keys.length === Object.keys(actual).length && keys.every((key) => same(actual[key], expected[key]));
|
|
455
|
+
}
|
|
456
|
+
function validateTimeScale(value, deltaT, instant, scale) {
|
|
457
|
+
const timeScale = record(value);
|
|
458
|
+
fields(timeScale, ["input", "basis", "ut1MinusUtc", "leapSeconds"]);
|
|
459
|
+
const basis = choice(timeScale.basis, ["iers", "delta-t", "pinned"]);
|
|
460
|
+
const { ut1MinusUtc, leapSeconds } = timeScale;
|
|
461
|
+
if (ut1MinusUtc !== null) {
|
|
462
|
+
const ut1 = record(ut1MinusUtc);
|
|
463
|
+
fields(ut1, ["seconds", "sigma", "source"]);
|
|
464
|
+
number(ut1.seconds, -1, 1);
|
|
465
|
+
number(ut1.sigma, 0, 1);
|
|
466
|
+
choice(ut1.source, IERS_SEGMENTS);
|
|
467
|
+
}
|
|
468
|
+
if (leapSeconds !== null) {
|
|
469
|
+
const leap = record(leapSeconds);
|
|
470
|
+
fields(leap, ["taiMinusUtc", "listed"]);
|
|
471
|
+
if (!Number.isInteger(number(leap.taiMinusUtc, 10, 100))) fail("invalid_value");
|
|
472
|
+
bool(leap.listed);
|
|
473
|
+
}
|
|
474
|
+
const iers = deltaT.model === DELTA_T_IERS_MODEL;
|
|
475
|
+
if (timeScale.input !== scale || basis === "pinned" !== (deltaT.model === "pinned") || basis === "iers" !== iers || iers && (ut1MinusUtc === null || leapSeconds === null))
|
|
476
|
+
fail("inconsistent_result");
|
|
477
|
+
if (deltaT.tableDigest === UT1_DATA.digest || deltaT.tableDigest === DELTA_T_TABLE.digest) {
|
|
478
|
+
const expected = timeBasis(Date.parse(instant), scale);
|
|
479
|
+
if (!same(deltaT, expected.deltaT) || !same(timeScale, expected.timeScale)) fail("inconsistent_result");
|
|
480
|
+
}
|
|
405
481
|
}
|
|
406
|
-
function validateResult(value, instantaneousApplying, instant) {
|
|
482
|
+
function validateResult(value, instantaneousApplying, instant, scale) {
|
|
407
483
|
const result = record(value);
|
|
408
|
-
fields(result, [
|
|
409
|
-
|
|
484
|
+
fields(result, [
|
|
485
|
+
"bodies",
|
|
486
|
+
"angles",
|
|
487
|
+
"houses",
|
|
488
|
+
"aspects",
|
|
489
|
+
...instant === null ? [] : ["deltaT"],
|
|
490
|
+
...scale === null ? [] : ["timeScale"]
|
|
491
|
+
]);
|
|
492
|
+
if (instant !== null) {
|
|
493
|
+
const deltaT = validateDeltaT(result.deltaT, instant, scale !== null);
|
|
494
|
+
if (scale !== null) validateTimeScale(result.timeScale, deltaT, instant, scale);
|
|
495
|
+
}
|
|
410
496
|
if (!Array.isArray(result.bodies) || result.bodies.length !== 12) fail("invalid_shape");
|
|
411
497
|
const names = /* @__PURE__ */ new Set();
|
|
412
498
|
const longitudes = /* @__PURE__ */ new Map();
|
|
@@ -509,13 +595,28 @@ function validateResult(value, instantaneousApplying, instant) {
|
|
|
509
595
|
}
|
|
510
596
|
return result;
|
|
511
597
|
}
|
|
512
|
-
|
|
598
|
+
var LOCAL_FIELDS = ["date", "time", "timeZone", "offsetMinutes", "gapShiftMinutes", "policy"];
|
|
599
|
+
var LOCAL_TIME_BASIS_FIELDS = [
|
|
600
|
+
"calendar",
|
|
601
|
+
"writtenDate",
|
|
602
|
+
"tzdbVersion",
|
|
603
|
+
"dataForm",
|
|
604
|
+
"clock",
|
|
605
|
+
"transition",
|
|
606
|
+
"localMeanTime"
|
|
607
|
+
];
|
|
608
|
+
function offsetMinutes(value) {
|
|
609
|
+
const minutes = number(value, -1440, 1440);
|
|
610
|
+
if (Math.abs(minutes * 6e4 - Math.round(minutes * 6e4)) > 1e-6) fail("invalid_context");
|
|
611
|
+
return minutes;
|
|
612
|
+
}
|
|
613
|
+
function validateLocal(value, receipt, timeBasis2) {
|
|
513
614
|
if (value === null) {
|
|
514
615
|
if (receipt.reference === "local-noon") fail("invalid_context");
|
|
515
616
|
return;
|
|
516
617
|
}
|
|
517
618
|
const local = record(value);
|
|
518
|
-
fields(local,
|
|
619
|
+
fields(local, LOCAL_FIELDS, timeBasis2 ? LOCAL_TIME_BASIS_FIELDS : []);
|
|
519
620
|
const date = text(local.date, 10), time = text(local.time, 5);
|
|
520
621
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(date) || !/^(?:[01]\d|2[0-3]):[0-5]\d$/.test(time))
|
|
521
622
|
fail("invalid_context");
|
|
@@ -535,9 +636,55 @@ function validateLocal(value, receipt) {
|
|
|
535
636
|
if (wall + Math.round(shiftMs) - Math.round(offsetMs) !== dateFrom(receipt.instant, "instant").getTime())
|
|
536
637
|
fail("invalid_context");
|
|
537
638
|
fixedFields(local.policy, { fold: "earlier", gap: "shift-forward" });
|
|
538
|
-
if (receipt.inputFlags.includes("dst-gap") !== shift > 0
|
|
539
|
-
fail("invalid_context");
|
|
639
|
+
if (receipt.inputFlags.includes("dst-gap") !== shift > 0) fail("invalid_context");
|
|
540
640
|
if (receipt.reference === "local-noon" && time !== "12:00") fail("invalid_context");
|
|
641
|
+
if (!timeBasis2) {
|
|
642
|
+
if (receipt.inputFlags.includes("lmt") !== Math.abs(offset % 1) > 1e-9) fail("invalid_context");
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
validateLocalRecord(local, receipt, date, offset, shift);
|
|
646
|
+
}
|
|
647
|
+
function validateLocalRecord(local, receipt, date, offset, shift) {
|
|
648
|
+
const has = (key) => Object.hasOwn(local, key);
|
|
649
|
+
const calendar = has("calendar") ? choice(local.calendar, ["gregorian", "julian"]) : "gregorian";
|
|
650
|
+
const written = has("writtenDate") ? text(local.writtenDate, 10) : null;
|
|
651
|
+
const version2 = has("tzdbVersion") ? local.tzdbVersion : void 0;
|
|
652
|
+
if (version2 !== void 0 && version2 !== null && (typeof version2 !== "string" || !/^\d{4}[a-z]$/.test(version2)))
|
|
653
|
+
fail("invalid_value");
|
|
654
|
+
const form = has("dataForm") ? choice(local.dataForm, ["main+backzone", "main", "host"]) : void 0;
|
|
655
|
+
const flags = receipt.inputFlags;
|
|
656
|
+
const lmt = has("clock") ? choice(local.clock, ["local-mean-time", "legal"]) === "local-mean-time" : flags.includes("lmt");
|
|
657
|
+
const gap = flags.includes("dst-gap");
|
|
658
|
+
const fold = flags.includes("dst-fold");
|
|
659
|
+
if (
|
|
660
|
+
// A local time resolves to UTC.
|
|
661
|
+
receipt.timeScale !== "utc" || written !== null && (!parseCalendarDate(written, calendar) || (calendar === "gregorian" ? written : julianToGregorian(written)) !== date) || form !== void 0 && form !== "host" && version2 === null || flags.includes("lmt") !== lmt || local.transition === null && (gap || fold)
|
|
662
|
+
)
|
|
663
|
+
fail("invalid_context");
|
|
664
|
+
let before2 = null;
|
|
665
|
+
if (has("transition") && local.transition !== null) {
|
|
666
|
+
const transition = record(local.transition);
|
|
667
|
+
fields(transition, ["at", "offsetBeforeMinutes", "offsetAfterMinutes", "cause"]);
|
|
668
|
+
const at = Date.parse(canonicalInstant(transition.at));
|
|
669
|
+
const instant = Date.parse(receipt.instant);
|
|
670
|
+
before2 = offsetMinutes(transition.offsetBeforeMinutes);
|
|
671
|
+
const after = offsetMinutes(transition.offsetAfterMinutes);
|
|
672
|
+
const near = (a, b) => Math.abs(a - b) <= 1e-9;
|
|
673
|
+
if (
|
|
674
|
+
// A change of half a day or more moves the date: a move across the date line.
|
|
675
|
+
choice(transition.cause, ["dst", "legal-change", "date-line"]) === "date-line" !== Math.abs(after - before2) >= 720 || !(gap ? after > before2 && near(after - before2, shift) && near(offset, after) && at <= instant : fold ? after < before2 && near(offset, before2) && at > instant : near(offset, after) && at <= instant)
|
|
676
|
+
)
|
|
677
|
+
fail("invalid_context");
|
|
678
|
+
}
|
|
679
|
+
if (has("localMeanTime") && local.localMeanTime !== null) {
|
|
680
|
+
const mean = record(local.localMeanTime);
|
|
681
|
+
fields(mean, ["longitude", "zoneOffsetMinutes"]);
|
|
682
|
+
const seconds = Math.round(number(mean.longitude, -180, 180) * 240);
|
|
683
|
+
offsetMinutes(mean.zoneOffsetMinutes);
|
|
684
|
+
const read = lmt ? offset : gap ? before2 : null;
|
|
685
|
+
if (read === null ? !(gap && !has("transition")) : (Math.round(read * 60) - seconds) % 86400 !== 0)
|
|
686
|
+
fail("invalid_context");
|
|
687
|
+
}
|
|
541
688
|
}
|
|
542
689
|
function repository(value) {
|
|
543
690
|
const input = text(value, 256);
|
|
@@ -617,7 +764,7 @@ function validateEnvelope(input) {
|
|
|
617
764
|
"provenance",
|
|
618
765
|
"conventions",
|
|
619
766
|
"coverage"
|
|
620
|
-
]);
|
|
767
|
+
], ["timeScale"]);
|
|
621
768
|
canonicalInstant(receipt.instant);
|
|
622
769
|
if (receipt.sourceInstant !== null) {
|
|
623
770
|
if (typeof receipt.sourceInstant !== "string" || receipt.sourceInstant.length > 40)
|
|
@@ -642,10 +789,15 @@ function validateEnvelope(input) {
|
|
|
642
789
|
if (timeKnown && Math.abs(coords.latitude) === 90) fail("unsupported_feature");
|
|
643
790
|
}
|
|
644
791
|
const conventions = conventionSet(receipt.conventions);
|
|
792
|
+
const current = conventions === CONVENTIONS || conventions === CONVENTIONS_RC8;
|
|
793
|
+
const timeBasis2 = conventions === CONVENTIONS;
|
|
794
|
+
if (timeBasis2 !== Object.hasOwn(receipt, "timeScale")) fail("invalid_shape");
|
|
795
|
+
const scale = timeBasis2 ? choice(receipt.timeScale, TIME_SCALE_NAMES) : null;
|
|
645
796
|
const result = validateResult(
|
|
646
797
|
envelope.result,
|
|
647
798
|
conventions !== CONVENTIONS_RC3,
|
|
648
|
-
|
|
799
|
+
current ? receipt.instant : null,
|
|
800
|
+
scale
|
|
649
801
|
);
|
|
650
802
|
const house = record(receipt.houses);
|
|
651
803
|
fields(house, ["requested", "actual", "absenceReason"]);
|
|
@@ -659,7 +811,6 @@ function validateEnvelope(input) {
|
|
|
659
811
|
if (result.houses && result.angles && TURNING_WITH_ASCENDANT.includes(result.houses.system) && !angularClose(result.houses.cusps[9], result.angles.mc) && Math.abs(receipt.coordinates.latitude) < 65)
|
|
660
812
|
fail("inconsistent_result");
|
|
661
813
|
const inputFlags = flagList(receipt.inputFlags, TIME_FLAGS);
|
|
662
|
-
const current = conventions === CONVENTIONS;
|
|
663
814
|
const resultFlags = flagList(receipt.resultFlags, current ? FLAGS : FLAGS_RC7);
|
|
664
815
|
const expected = [...inputFlags];
|
|
665
816
|
if (!timeKnown) expected.push("no-time");
|
|
@@ -679,8 +830,8 @@ function validateEnvelope(input) {
|
|
|
679
830
|
version(ephemeris.version);
|
|
680
831
|
}
|
|
681
832
|
validateProvenance(receipt.provenance, engineVersion);
|
|
682
|
-
validateLocal(receipt.localResolution, receipt);
|
|
683
|
-
if (conventions === CONVENTIONS_RC3 && !RC3_TO_RC6.test(engineVersion) || conventions === CONVENTIONS_RC7 && !RC7.test(engineVersion) ||
|
|
833
|
+
validateLocal(receipt.localResolution, receipt, timeBasis2);
|
|
834
|
+
if (conventions === CONVENTIONS_RC3 && !RC3_TO_RC6.test(engineVersion) || conventions === CONVENTIONS_RC7 && !RC7.test(engineVersion) || conventions === CONVENTIONS_RC8 && !RC8_TO_RC14.test(engineVersion) || timeBasis2 && before(engineVersion, TIME_BASIS_RELEASE) || !HOUSE_SYSTEMS_BEFORE_RC9.includes(requested) && before(engineVersion, RC9_RELEASE) || !HOUSE_SYSTEMS_BEFORE_RC10.includes(requested) && before(engineVersion, RC10_RELEASE))
|
|
684
835
|
fail("inconsistent_result");
|
|
685
836
|
fixedFields(receipt.coverage, COVERAGE);
|
|
686
837
|
if (envelope.extensions !== void 0) record(envelope.extensions);
|
|
@@ -707,13 +858,14 @@ function createNatalEnvelope(chart, context = {}) {
|
|
|
707
858
|
"aspects",
|
|
708
859
|
"flags",
|
|
709
860
|
"deltaT",
|
|
861
|
+
"timeScale",
|
|
710
862
|
"engineVersion"
|
|
711
863
|
]);
|
|
712
864
|
const input = record(source.input);
|
|
713
865
|
fields(
|
|
714
866
|
input,
|
|
715
867
|
["utc", "houseSystem", "timeKnown"],
|
|
716
|
-
["latitude", "longitude", "flags", "deltaT"]
|
|
868
|
+
["latitude", "longitude", "flags", "deltaT", "timeScale"]
|
|
717
869
|
);
|
|
718
870
|
if (!(input.utc instanceof Date)) fail("invalid_value");
|
|
719
871
|
const supplied = record(cloneData(context));
|
|
@@ -732,6 +884,7 @@ function createNatalEnvelope(chart, context = {}) {
|
|
|
732
884
|
receipt: {
|
|
733
885
|
schema: NATAL_RECEIPT_SCHEMA,
|
|
734
886
|
instant: Date.prototype.toISOString.call(input.utc),
|
|
887
|
+
timeScale: input.timeScale ?? "utc",
|
|
735
888
|
sourceInstant: supplied.sourceInstant === void 0 ? null : supplied.sourceInstant,
|
|
736
889
|
timeKnown: input.timeKnown,
|
|
737
890
|
reference: supplied.reference === void 0 ? "supplied-instant" : supplied.reference,
|
|
@@ -758,7 +911,8 @@ function createNatalEnvelope(chart, context = {}) {
|
|
|
758
911
|
angles: source.angles,
|
|
759
912
|
houses: source.houses,
|
|
760
913
|
aspects: source.aspects,
|
|
761
|
-
deltaT: source.deltaT
|
|
914
|
+
deltaT: source.deltaT,
|
|
915
|
+
timeScale: source.timeScale
|
|
762
916
|
},
|
|
763
917
|
...supplied.extensions === void 0 ? {} : { extensions: supplied.extensions }
|
|
764
918
|
};
|
|
@@ -788,6 +942,7 @@ function natalReplayInput(envelope) {
|
|
|
788
942
|
const { receipt, result } = checked(envelope);
|
|
789
943
|
return {
|
|
790
944
|
utc: receipt.instant,
|
|
945
|
+
...receipt.timeScale === void 0 || receipt.timeScale === "utc" ? {} : { timeScale: receipt.timeScale },
|
|
791
946
|
houseSystem: receipt.houses.requested,
|
|
792
947
|
timeKnown: receipt.timeKnown,
|
|
793
948
|
flags: [...receipt.inputFlags],
|