siderust-js 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/.github/workflows/ci.yml +166 -0
- package/.gitmodules +9 -0
- package/CHANGELOG.md +26 -0
- package/LICENSE +661 -0
- package/README.md +138 -0
- package/package.json +12 -0
- package/qtty-js/.github/workflows/ci.yml +151 -0
- package/qtty-js/.gitmodules +3 -0
- package/qtty-js/CHANGELOG.md +31 -0
- package/qtty-js/LICENSE +661 -0
- package/qtty-js/README.md +132 -0
- package/qtty-js/package.json +20 -0
- package/qtty-js/qtty/.github/workflows/ci.yml +155 -0
- package/qtty-js/qtty/CHANGELOG.md +120 -0
- package/qtty-js/qtty/Cargo.lock +1462 -0
- package/qtty-js/qtty/Cargo.toml +12 -0
- package/qtty-js/qtty/LICENSE +661 -0
- package/qtty-js/qtty/README.md +9 -0
- package/qtty-js/qtty/qtty/Cargo.toml +41 -0
- package/qtty-js/qtty/qtty/README.md +8 -0
- package/qtty-js/qtty/qtty/examples/angles.rs +14 -0
- package/qtty-js/qtty/qtty/examples/astronomy.rs +17 -0
- package/qtty-js/qtty/qtty/examples/dimensional_arithmetic.rs +83 -0
- package/qtty-js/qtty/qtty/examples/python_integration.rs +61 -0
- package/qtty-js/qtty/qtty/examples/quickstart.rs +15 -0
- package/qtty-js/qtty/qtty/examples/ratios.rs +12 -0
- package/qtty-js/qtty/qtty/examples/serde_with_unit.rs +234 -0
- package/qtty-js/qtty/qtty/examples/serialization.rs +141 -0
- package/qtty-js/qtty/qtty/examples/serialization_advanced.rs +155 -0
- package/qtty-js/qtty/qtty/src/f32.rs +108 -0
- package/qtty-js/qtty/qtty/src/f64.rs +30 -0
- package/qtty-js/qtty/qtty/src/i128.rs +111 -0
- package/qtty-js/qtty/qtty/src/i16.rs +111 -0
- package/qtty-js/qtty/qtty/src/i32.rs +111 -0
- package/qtty-js/qtty/qtty/src/i64.rs +111 -0
- package/qtty-js/qtty/qtty/src/i8.rs +111 -0
- package/qtty-js/qtty/qtty/src/lib.rs +238 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std/Cargo.lock +83 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std/Cargo.toml +10 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std/src/lib.rs +7 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std-alloc/Cargo.lock +83 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std-alloc/Cargo.toml +10 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std-alloc/src/lib.rs +7 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-std/Cargo.lock +83 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-std/Cargo.toml +10 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-std/src/lib.rs +5 -0
- package/qtty-js/qtty/qtty/tests/integration_tests.rs +529 -0
- package/qtty-js/qtty/qtty/tests/qtty_vec_feature_matrix.rs +58 -0
- package/qtty-js/qtty/qtty-core/Cargo.toml +41 -0
- package/qtty-js/qtty/qtty-core/README.md +8 -0
- package/qtty-js/qtty/qtty-core/examples/diesel_integration.rs +145 -0
- package/qtty-js/qtty/qtty-core/examples/quantity_db_serde.rs +215 -0
- package/qtty-js/qtty/qtty-core/src/dimension.rs +249 -0
- package/qtty-js/qtty/qtty-core/src/feature_diesel.rs +318 -0
- package/qtty-js/qtty/qtty-core/src/feature_pyo3.rs +27 -0
- package/qtty-js/qtty/qtty-core/src/feature_serde.rs +203 -0
- package/qtty-js/qtty/qtty-core/src/feature_tiberius.rs +28 -0
- package/qtty-js/qtty/qtty-core/src/lib.rs +744 -0
- package/qtty-js/qtty/qtty-core/src/macros.rs +93 -0
- package/qtty-js/qtty/qtty-core/src/quantity.rs +810 -0
- package/qtty-js/qtty/qtty-core/src/scalar.rs +1742 -0
- package/qtty-js/qtty/qtty-core/src/unit.rs +332 -0
- package/qtty-js/qtty/qtty-core/src/units/angular.rs +1228 -0
- package/qtty-js/qtty/qtty-core/src/units/area.rs +243 -0
- package/qtty-js/qtty/qtty-core/src/units/frequency.rs +179 -0
- package/qtty-js/qtty/qtty-core/src/units/length.rs +1270 -0
- package/qtty-js/qtty/qtty-core/src/units/mass.rs +488 -0
- package/qtty-js/qtty/qtty-core/src/units/mod.rs +26 -0
- package/qtty-js/qtty/qtty-core/src/units/power.rs +324 -0
- package/qtty-js/qtty/qtty-core/src/units/time.rs +667 -0
- package/qtty-js/qtty/qtty-core/src/units/unitless.rs +212 -0
- package/qtty-js/qtty/qtty-core/src/units/velocity.rs +210 -0
- package/qtty-js/qtty/qtty-core/src/units/volume.rs +269 -0
- package/qtty-js/qtty/qtty-core/tests/core.rs +628 -0
- package/qtty-js/qtty/qtty-core/tests/diesel.rs +461 -0
- package/qtty-js/qtty/qtty-core/tests/integers.rs +632 -0
- package/qtty-js/qtty/qtty-core/tests/no_cross_unit_ops.rs +35 -0
- package/qtty-js/qtty/qtty-core/tests/pyo3.rs +334 -0
- package/qtty-js/qtty/qtty-core/tests/quantity_f32.rs +276 -0
- package/qtty-js/qtty/qtty-core/tests/scalar_decimal.rs +258 -0
- package/qtty-js/qtty/qtty-core/tests/scalar_f32.rs +286 -0
- package/qtty-js/qtty/qtty-core/tests/scalar_f64_real.rs +287 -0
- package/qtty-js/qtty/qtty-core/tests/scalar_rational.rs +260 -0
- package/qtty-js/qtty/qtty-core/tests/serde.rs +256 -0
- package/qtty-js/qtty/qtty-core/tests/tiberius.rs +208 -0
- package/qtty-js/qtty/qtty-derive/Cargo.toml +23 -0
- package/qtty-js/qtty/qtty-derive/README.md +8 -0
- package/qtty-js/qtty/qtty-derive/src/lib.rs +340 -0
- package/qtty-js/qtty/qtty-ffi/ARCHITECTURE.md +3 -0
- package/qtty-js/qtty/qtty-ffi/Cargo.toml +31 -0
- package/qtty-js/qtty/qtty-ffi/README.md +9 -0
- package/qtty-js/qtty/qtty-ffi/build.rs +326 -0
- package/qtty-js/qtty/qtty-ffi/cbindgen.toml +105 -0
- package/qtty-js/qtty/qtty-ffi/include/qtty_ffi.h +1126 -0
- package/qtty-js/qtty/qtty-ffi/src/ffi.rs +1251 -0
- package/qtty-js/qtty/qtty-ffi/src/ffi_serde.rs +294 -0
- package/qtty-js/qtty/qtty-ffi/src/helpers.rs +310 -0
- package/qtty-js/qtty/qtty-ffi/src/lib.rs +229 -0
- package/qtty-js/qtty/qtty-ffi/src/macros.rs +121 -0
- package/qtty-js/qtty/qtty-ffi/src/registry.rs +274 -0
- package/qtty-js/qtty/qtty-ffi/src/types.rs +620 -0
- package/qtty-js/qtty/qtty-ffi/tests/integration_tests.rs +842 -0
- package/qtty-js/qtty/qtty-ffi/units.csv +156 -0
- package/qtty-js/qtty/qtty-ffi/units.csv.md +3 -0
- package/qtty-js/qtty-node/.prettierignore +6 -0
- package/qtty-js/qtty-node/.prettierrc.json +6 -0
- package/qtty-js/qtty-node/README.md +250 -0
- package/qtty-js/qtty-node/c8.config.json +11 -0
- package/qtty-js/qtty-node/eslint.config.js +31 -0
- package/qtty-js/qtty-node/examples/arithmetic.mjs +64 -0
- package/qtty-js/qtty-node/examples/astronomy.mjs +90 -0
- package/qtty-js/qtty-node/examples/quickstart.mjs +36 -0
- package/qtty-js/qtty-node/examples/serialization.mjs +125 -0
- package/qtty-js/qtty-node/examples/unit_factories.mjs +74 -0
- package/qtty-js/qtty-node/index.d.ts +219 -0
- package/qtty-js/qtty-node/index.js +323 -0
- package/qtty-js/qtty-node/lib/DerivedQuantity.js +122 -0
- package/qtty-js/qtty-node/lib/Quantity.js +151 -0
- package/qtty-js/qtty-node/lib/backend.js +25 -0
- package/qtty-js/qtty-node/native.cjs +306 -0
- package/qtty-js/qtty-node/package-lock.json +3223 -0
- package/qtty-js/qtty-node/package.json +70 -0
- package/qtty-js/qtty-node/units.d.ts +299 -0
- package/qtty-js/qtty-node/units.js +210 -0
- package/qtty-js/qtty-web/Cargo.lock +767 -0
- package/qtty-js/qtty-web/Cargo.toml +21 -0
- package/qtty-js/qtty-web/index.d.ts +140 -0
- package/qtty-js/qtty-web/index.js +20 -0
- package/qtty-js/qtty-web/lib/DerivedQuantity.js +58 -0
- package/qtty-js/qtty-web/lib/Quantity.js +75 -0
- package/qtty-js/qtty-web/lib/backend.js +80 -0
- package/qtty-js/qtty-web/package.json +45 -0
- package/qtty-js/qtty-web/src/lib.rs +111 -0
- package/qtty-js/scripts/ci.sh +73 -0
- package/scripts/ci.sh +123 -0
- package/siderust-core/Cargo.lock +787 -0
- package/siderust-core/Cargo.toml +18 -0
- package/siderust-core/DEDUPLICATION.md +124 -0
- package/siderust-core/src/body.rs +120 -0
- package/siderust-core/src/events.rs +184 -0
- package/siderust-core/src/lib.rs +20 -0
- package/siderust-core/src/observer.rs +55 -0
- package/siderust-core/src/position.rs +213 -0
- package/siderust-node/.prettierignore +7 -0
- package/siderust-node/.prettierrc.json +6 -0
- package/siderust-node/Cargo.lock +906 -0
- package/siderust-node/Cargo.toml +29 -0
- package/siderust-node/README.md +109 -0
- package/siderust-node/__test__/index.test.mjs +248 -0
- package/siderust-node/build.rs +5 -0
- package/siderust-node/c8.config.json +3 -0
- package/siderust-node/eslint.config.js +31 -0
- package/siderust-node/examples/01_basic_coordinates.mjs +24 -0
- package/siderust-node/examples/02_coordinate_transformations.mjs +25 -0
- package/siderust-node/examples/03_all_frames_conversions.mjs +26 -0
- package/siderust-node/examples/04_all_center_conversions.mjs +24 -0
- package/siderust-node/examples/05_target_tracking.mjs +22 -0
- package/siderust-node/examples/06_night_events.mjs +18 -0
- package/siderust-node/examples/07_moon_properties.mjs +21 -0
- package/siderust-node/examples/08_solar_system.mjs +19 -0
- package/siderust-node/examples/09_star_observability.mjs +22 -0
- package/siderust-node/examples/10_time_periods.mjs +9 -0
- package/siderust-node/examples/11_serialization.mjs +31 -0
- package/siderust-node/examples/12_runtime_ephemeris.mjs +27 -0
- package/siderust-node/examples/13_coordinate_operations.mjs +20 -0
- package/siderust-node/index.d.ts +623 -0
- package/siderust-node/index.js +79 -0
- package/siderust-node/lib/Observer.js +112 -0
- package/siderust-node/lib/Star.js +118 -0
- package/siderust-node/lib/backend.js +63 -0
- package/siderust-node/lib/wrappers.js +566 -0
- package/siderust-node/main.js +20 -0
- package/siderust-node/native.cjs +360 -0
- package/siderust-node/package-lock.json +3261 -0
- package/siderust-node/package.json +71 -0
- package/siderust-node/src/body.rs +74 -0
- package/siderust-node/src/coordinates.rs +372 -0
- package/siderust-node/src/ephemeris.rs +462 -0
- package/siderust-node/src/events.rs +577 -0
- package/siderust-node/src/lib.rs +43 -0
- package/siderust-node/src/observer.rs +132 -0
- package/siderust-node/src/phase.rs +218 -0
- package/siderust-node/src/position.rs +292 -0
- package/siderust-node/src/star.rs +200 -0
- package/siderust-web/Cargo.lock +855 -0
- package/siderust-web/Cargo.toml +34 -0
- package/siderust-web/README.md +100 -0
- package/siderust-web/__test__/index.test.mjs +118 -0
- package/siderust-web/examples/github-pages/README.md +31 -0
- package/siderust-web/examples/github-pages/index.html +135 -0
- package/siderust-web/index.d.ts +311 -0
- package/siderust-web/index.js +66 -0
- package/siderust-web/lib/Observer.js +103 -0
- package/siderust-web/lib/Star.js +116 -0
- package/siderust-web/lib/backend.js +400 -0
- package/siderust-web/lib/wrappers.js +512 -0
- package/siderust-web/package.json +55 -0
- package/siderust-web/src/body.rs +69 -0
- package/siderust-web/src/coordinates.rs +302 -0
- package/siderust-web/src/ephemeris.rs +456 -0
- package/siderust-web/src/events.rs +520 -0
- package/siderust-web/src/lib.rs +51 -0
- package/siderust-web/src/observer.rs +117 -0
- package/siderust-web/src/phase.rs +190 -0
- package/siderust-web/src/position.rs +291 -0
- package/siderust-web/src/star.rs +178 -0
- package/tempoch-js/.github/workflows/ci.yml +142 -0
- package/tempoch-js/.gitmodules +3 -0
- package/tempoch-js/CHANGELOG.md +25 -0
- package/tempoch-js/LICENSE +661 -0
- package/tempoch-js/README.md +126 -0
- package/tempoch-js/package.json +20 -0
- package/tempoch-js/scripts/ci.sh +73 -0
- package/tempoch-js/tempoch/.github/workflows/ci.yml +113 -0
- package/tempoch-js/tempoch/CHANGELOG.md +82 -0
- package/tempoch-js/tempoch/Cargo.lock +947 -0
- package/tempoch-js/tempoch/Cargo.toml +3 -0
- package/tempoch-js/tempoch/LICENSE +661 -0
- package/tempoch-js/tempoch/README.md +76 -0
- package/tempoch-js/tempoch/tempoch/Cargo.toml +27 -0
- package/tempoch-js/tempoch/tempoch/examples/periods.rs +45 -0
- package/tempoch-js/tempoch/tempoch/examples/quickstart.rs +13 -0
- package/tempoch-js/tempoch/tempoch/src/lib.rs +49 -0
- package/tempoch-js/tempoch/tempoch/tests/integration.rs +57 -0
- package/tempoch-js/tempoch/tempoch-core/Cargo.toml +24 -0
- package/tempoch-js/tempoch/tempoch-core/src/delta_t.rs +345 -0
- package/tempoch-js/tempoch/tempoch-core/src/instant.rs +811 -0
- package/tempoch-js/tempoch/tempoch-core/src/julian_date_ext.rs +142 -0
- package/tempoch-js/tempoch/tempoch-core/src/lib.rs +81 -0
- package/tempoch-js/tempoch/tempoch-core/src/period.rs +1168 -0
- package/tempoch-js/tempoch/tempoch-core/src/scales.rs +779 -0
- package/tempoch-js/tempoch/tempoch-ffi/Cargo.lock +889 -0
- package/tempoch-js/tempoch/tempoch-ffi/Cargo.toml +26 -0
- package/tempoch-js/tempoch/tempoch-ffi/build.rs +24 -0
- package/tempoch-js/tempoch/tempoch-ffi/cbindgen.toml +30 -0
- package/tempoch-js/tempoch/tempoch-ffi/src/error.rs +19 -0
- package/tempoch-js/tempoch/tempoch-ffi/src/lib.rs +82 -0
- package/tempoch-js/tempoch/tempoch-ffi/src/period.rs +101 -0
- package/tempoch-js/tempoch/tempoch-ffi/src/time.rs +711 -0
- package/tempoch-js/tempoch/tempoch-ffi/tests/ffi.rs +265 -0
- package/tempoch-js/tempoch-node/.prettierignore +6 -0
- package/tempoch-js/tempoch-node/.prettierrc.json +6 -0
- package/tempoch-js/tempoch-node/Cargo.lock +496 -0
- package/tempoch-js/tempoch-node/Cargo.toml +29 -0
- package/tempoch-js/tempoch-node/README.md +265 -0
- package/tempoch-js/tempoch-node/__test__/index.test.mjs +598 -0
- package/tempoch-js/tempoch-node/build.rs +5 -0
- package/tempoch-js/tempoch-node/c8.config.json +3 -0
- package/tempoch-js/tempoch-node/eslint.config.js +31 -0
- package/tempoch-js/tempoch-node/examples/periods.mjs +79 -0
- package/tempoch-js/tempoch-node/examples/quickstart.mjs +71 -0
- package/tempoch-js/tempoch-node/examples/timescales.mjs +92 -0
- package/tempoch-js/tempoch-node/index.d.ts +280 -0
- package/tempoch-js/tempoch-node/index.js +32 -0
- package/tempoch-js/tempoch-node/lib/JulianDate.js +176 -0
- package/tempoch-js/tempoch-node/lib/ModifiedJulianDate.js +156 -0
- package/tempoch-js/tempoch-node/lib/Period.js +133 -0
- package/tempoch-js/tempoch-node/lib/backend.js +38 -0
- package/tempoch-js/tempoch-node/lib/qttyCompat.js +92 -0
- package/tempoch-js/tempoch-node/native.cjs +317 -0
- package/tempoch-js/tempoch-node/package-lock.json +3223 -0
- package/tempoch-js/tempoch-node/package.json +56 -0
- package/tempoch-js/tempoch-node/src/lib.rs +573 -0
- package/tempoch-js/tempoch-web/Cargo.toml +23 -0
- package/tempoch-js/tempoch-web/index.d.ts +95 -0
- package/tempoch-js/tempoch-web/index.js +27 -0
- package/tempoch-js/tempoch-web/lib/JulianDate.js +170 -0
- package/tempoch-js/tempoch-web/lib/ModifiedJulianDate.js +145 -0
- package/tempoch-js/tempoch-web/lib/Period.js +121 -0
- package/tempoch-js/tempoch-web/lib/backend.js +118 -0
- package/tempoch-js/tempoch-web/package.json +46 -0
- package/tempoch-js/tempoch-web/src/lib.rs +184 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
import { Quantity } from '@siderust/qtty-web'
|
|
5
|
+
|
|
6
|
+
// ── Initialization ──────────────────────────────────────────────────
|
|
7
|
+
/**
|
|
8
|
+
* Initialise the WASM module. Must be awaited before calling any other
|
|
9
|
+
* function in this package.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { init } from '@siderust/tempoch-web';
|
|
13
|
+
* await init(); // or init(wasmUrl)
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function init(
|
|
17
|
+
module_or_path?: RequestInfo | URL | Response | BufferSource | WebAssembly.Module
|
|
18
|
+
): Promise<void>
|
|
19
|
+
|
|
20
|
+
// ── Interfaces ──────────────────────────────────────────────────────
|
|
21
|
+
|
|
22
|
+
export interface UtcBounds {
|
|
23
|
+
startMs: number
|
|
24
|
+
endMs: number
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// ── Free functions ──────────────────────────────────────────────────
|
|
28
|
+
|
|
29
|
+
export declare function jdToMjd(jd: number): number
|
|
30
|
+
export declare function mjdToJd(mjd: number): number
|
|
31
|
+
export declare function julianCenturies(jd: number): number
|
|
32
|
+
export declare function julianYears(jd: number): number
|
|
33
|
+
export declare function jdFromDate(date: Date): number
|
|
34
|
+
export declare function mjdFromDate(date: Date): number
|
|
35
|
+
export declare function jdToDate(jd: number): Date
|
|
36
|
+
export declare function mjdToDate(mjd: number): Date
|
|
37
|
+
export declare function jdDifference(jd1: number, jd2: number): number
|
|
38
|
+
export declare function mjdDifference(mjd1: number, mjd2: number): number
|
|
39
|
+
export declare function version(): string
|
|
40
|
+
|
|
41
|
+
// ── JulianDate ──────────────────────────────────────────────────────
|
|
42
|
+
|
|
43
|
+
export declare class JulianDate {
|
|
44
|
+
constructor(value: number)
|
|
45
|
+
static fromDate(date: Date): JulianDate
|
|
46
|
+
static fromUtc(year: number, month: number, day: number, hour: number, minute: number, second: number): JulianDate
|
|
47
|
+
static j2000(): JulianDate
|
|
48
|
+
get value(): number
|
|
49
|
+
get days(): Quantity
|
|
50
|
+
toMjd(): ModifiedJulianDate
|
|
51
|
+
toDate(): Date
|
|
52
|
+
julianCenturies(): Quantity
|
|
53
|
+
julianYears(): Quantity
|
|
54
|
+
add(duration: Quantity | number): JulianDate
|
|
55
|
+
sub(duration: Quantity | number): JulianDate
|
|
56
|
+
/** @deprecated Use `add()` instead. */
|
|
57
|
+
addDays(days: number): JulianDate
|
|
58
|
+
difference(other: JulianDate): Quantity
|
|
59
|
+
format(): string
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ── ModifiedJulianDate ──────────────────────────────────────────────
|
|
63
|
+
|
|
64
|
+
export declare class ModifiedJulianDate {
|
|
65
|
+
constructor(value: number)
|
|
66
|
+
static fromDate(date: Date): ModifiedJulianDate
|
|
67
|
+
static fromUtc(year: number, month: number, day: number, hour: number, minute: number, second: number): ModifiedJulianDate
|
|
68
|
+
get value(): number
|
|
69
|
+
get days(): Quantity
|
|
70
|
+
toJd(): JulianDate
|
|
71
|
+
toDate(): Date
|
|
72
|
+
add(duration: Quantity | number): ModifiedJulianDate
|
|
73
|
+
sub(duration: Quantity | number): ModifiedJulianDate
|
|
74
|
+
/** @deprecated Use `add()` instead. */
|
|
75
|
+
addDays(days: number): ModifiedJulianDate
|
|
76
|
+
difference(other: ModifiedJulianDate): Quantity
|
|
77
|
+
format(): string
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ── Period ───────────────────────────────────────────────────────────
|
|
81
|
+
|
|
82
|
+
export declare class Period {
|
|
83
|
+
constructor(start: number | ModifiedJulianDate, end: number | ModifiedJulianDate)
|
|
84
|
+
static fromDates(start: Date, end: Date): Period
|
|
85
|
+
get startMjd(): number
|
|
86
|
+
get endMjd(): number
|
|
87
|
+
get start(): ModifiedJulianDate
|
|
88
|
+
get end(): ModifiedJulianDate
|
|
89
|
+
duration(): Quantity
|
|
90
|
+
durationDays(): number
|
|
91
|
+
intersection(other: Period): Period | null
|
|
92
|
+
contains(mjd: number | ModifiedJulianDate): boolean
|
|
93
|
+
toUtc(): UtcBounds
|
|
94
|
+
format(): string
|
|
95
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @siderust/tempoch-web — Astronomical time primitives for the browser.
|
|
3
|
+
*
|
|
4
|
+
* Call `init()` before using any other function.
|
|
5
|
+
*
|
|
6
|
+
* @module @siderust/tempoch-web
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export { init } from './lib/backend.js';
|
|
10
|
+
export { JulianDate } from './lib/JulianDate.js';
|
|
11
|
+
export { ModifiedJulianDate } from './lib/ModifiedJulianDate.js';
|
|
12
|
+
export { Period } from './lib/Period.js';
|
|
13
|
+
|
|
14
|
+
// Free functions re-exported from the backend
|
|
15
|
+
export {
|
|
16
|
+
jdToMjd,
|
|
17
|
+
mjdToJd,
|
|
18
|
+
julianCenturies,
|
|
19
|
+
julianYears,
|
|
20
|
+
jdFromDate,
|
|
21
|
+
mjdFromDate,
|
|
22
|
+
jdToDate,
|
|
23
|
+
mjdToDate,
|
|
24
|
+
jdDifference,
|
|
25
|
+
mjdDifference,
|
|
26
|
+
version,
|
|
27
|
+
} from './lib/backend.js';
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @siderust/tempoch-web — JulianDate façade class (ESM/browser).
|
|
3
|
+
*
|
|
4
|
+
* @module @siderust/tempoch-web/lib/JulianDate
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Quantity, convert } from '@siderust/qtty-web';
|
|
8
|
+
import * as backend from './backend.js';
|
|
9
|
+
|
|
10
|
+
export class JulianDate {
|
|
11
|
+
/**
|
|
12
|
+
* Create a Julian Date from a raw scalar (days since the Julian Period).
|
|
13
|
+
* @param {number} value
|
|
14
|
+
*/
|
|
15
|
+
constructor(value) {
|
|
16
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
17
|
+
throw new Error('Julian date value must be finite (not NaN or ±infinity)');
|
|
18
|
+
}
|
|
19
|
+
this._value = value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Create a Julian Date from a JavaScript `Date` object.
|
|
24
|
+
* @param {Date} date
|
|
25
|
+
* @returns {JulianDate}
|
|
26
|
+
*/
|
|
27
|
+
static fromDate(date) {
|
|
28
|
+
return new JulianDate(backend.jdFromDate(date));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Create a Julian Date from explicit UTC components.
|
|
33
|
+
* @param {number} year
|
|
34
|
+
* @param {number} month
|
|
35
|
+
* @param {number} day
|
|
36
|
+
* @param {number} hour
|
|
37
|
+
* @param {number} minute
|
|
38
|
+
* @param {number} second
|
|
39
|
+
* @returns {JulianDate}
|
|
40
|
+
*/
|
|
41
|
+
static fromUtc(year, month, day, hour, minute, second) {
|
|
42
|
+
return new JulianDate(backend.jdFromUtc(year, month, day, hour, minute, second));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The J2000.0 epoch — JD 2 451 545.0. */
|
|
46
|
+
static j2000() {
|
|
47
|
+
return new JulianDate(2_451_545.0);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Raw Julian Date value. */
|
|
51
|
+
get value() {
|
|
52
|
+
return this._value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The JD value as a `Quantity` in Days. */
|
|
56
|
+
get days() {
|
|
57
|
+
return new Quantity(this._value, 'Day');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Convert to a `ModifiedJulianDate`.
|
|
62
|
+
* @returns {import('./ModifiedJulianDate.js').ModifiedJulianDate}
|
|
63
|
+
*/
|
|
64
|
+
toMjd() {
|
|
65
|
+
// Lazy import to break circular dependency (ESM live bindings
|
|
66
|
+
// are resolved by the time this method is actually called).
|
|
67
|
+
const { ModifiedJulianDate } = require_mjd();
|
|
68
|
+
return new ModifiedJulianDate(backend.jdToMjd(this._value));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Convert to a JavaScript `Date` (UTC). */
|
|
72
|
+
toDate() {
|
|
73
|
+
return backend.jdToDate(this._value);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Julian centuries since J2000.0 (T).
|
|
78
|
+
* @returns {Quantity}
|
|
79
|
+
*/
|
|
80
|
+
julianCenturies() {
|
|
81
|
+
return new Quantity(backend.julianCenturies(this._value), 'JulianCentury');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Julian years since J2000.0.
|
|
86
|
+
* @returns {Quantity}
|
|
87
|
+
*/
|
|
88
|
+
julianYears() {
|
|
89
|
+
return new Quantity(backend.julianYears(this._value), 'JulianYear');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Add a time duration (Quantity or number of days).
|
|
94
|
+
* @param {Quantity | number} duration
|
|
95
|
+
* @returns {JulianDate}
|
|
96
|
+
*/
|
|
97
|
+
add(duration) {
|
|
98
|
+
return new JulianDate(this._value + _toDays(duration));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Subtract a time duration.
|
|
103
|
+
* @param {Quantity | number} duration
|
|
104
|
+
* @returns {JulianDate}
|
|
105
|
+
*/
|
|
106
|
+
sub(duration) {
|
|
107
|
+
return new JulianDate(this._value - _toDays(duration));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Add a duration in days.
|
|
112
|
+
* @param {number} days
|
|
113
|
+
* @returns {JulianDate}
|
|
114
|
+
* @deprecated Use `add()` instead.
|
|
115
|
+
*/
|
|
116
|
+
addDays(days) {
|
|
117
|
+
if (!Number.isFinite(days)) throw new Error('days must be finite');
|
|
118
|
+
return new JulianDate(this._value + days);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Signed difference `self − other` as a Quantity in Days.
|
|
123
|
+
* @param {JulianDate} other
|
|
124
|
+
* @returns {Quantity}
|
|
125
|
+
*/
|
|
126
|
+
difference(other) {
|
|
127
|
+
return new Quantity(this._value - other._value, 'Day');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Human-readable representation. */
|
|
131
|
+
format() {
|
|
132
|
+
return `Julian Day: ${this._value} d`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Deferred module reference for breaking circular import
|
|
137
|
+
let _mjdModule = null;
|
|
138
|
+
function require_mjd() {
|
|
139
|
+
if (!_mjdModule) {
|
|
140
|
+
// By the time toMjd() is called both modules are fully loaded,
|
|
141
|
+
// so the circular reference is already resolved.
|
|
142
|
+
_mjdModule = { ModifiedJulianDate: null };
|
|
143
|
+
import('./ModifiedJulianDate.js').then(m => { _mjdModule.ModifiedJulianDate = m.ModifiedJulianDate; });
|
|
144
|
+
}
|
|
145
|
+
return _mjdModule;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Eagerly resolve the deferred import (runs after this module's body)
|
|
149
|
+
import('./ModifiedJulianDate.js').then(m => {
|
|
150
|
+
_mjdModule = { ModifiedJulianDate: m.ModifiedJulianDate };
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Convert a duration argument to days (number).
|
|
155
|
+
* @param {Quantity | number} d
|
|
156
|
+
* @returns {number}
|
|
157
|
+
*/
|
|
158
|
+
function _toDays(d) {
|
|
159
|
+
if (typeof d === 'number') {
|
|
160
|
+
if (!Number.isFinite(d)) throw new Error('Duration must be finite');
|
|
161
|
+
return d;
|
|
162
|
+
}
|
|
163
|
+
if (d && typeof d.value === 'number' && typeof d.unit === 'string') {
|
|
164
|
+
if (d.dimension !== 'Time') {
|
|
165
|
+
throw new Error(`Expected a time Quantity, got ${d.dimension}`);
|
|
166
|
+
}
|
|
167
|
+
return convert(d.value, d.unit, 'Day');
|
|
168
|
+
}
|
|
169
|
+
throw new Error('Expected a Quantity or number');
|
|
170
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @siderust/tempoch-web — ModifiedJulianDate façade class (ESM/browser).
|
|
3
|
+
*
|
|
4
|
+
* @module @siderust/tempoch-web/lib/ModifiedJulianDate
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Quantity, convert } from '@siderust/qtty-web';
|
|
8
|
+
import * as backend from './backend.js';
|
|
9
|
+
|
|
10
|
+
export class ModifiedJulianDate {
|
|
11
|
+
/**
|
|
12
|
+
* Create a Modified Julian Date from a raw scalar.
|
|
13
|
+
* @param {number} value
|
|
14
|
+
*/
|
|
15
|
+
constructor(value) {
|
|
16
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
17
|
+
throw new Error('MJD value must be finite (not NaN or ±infinity)');
|
|
18
|
+
}
|
|
19
|
+
this._value = value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Create a Modified Julian Date from a JavaScript `Date` object.
|
|
24
|
+
* @param {Date} date
|
|
25
|
+
* @returns {ModifiedJulianDate}
|
|
26
|
+
*/
|
|
27
|
+
static fromDate(date) {
|
|
28
|
+
return new ModifiedJulianDate(backend.mjdFromDate(date));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Create a Modified Julian Date from explicit UTC components.
|
|
33
|
+
* @param {number} year
|
|
34
|
+
* @param {number} month
|
|
35
|
+
* @param {number} day
|
|
36
|
+
* @param {number} hour
|
|
37
|
+
* @param {number} minute
|
|
38
|
+
* @param {number} second
|
|
39
|
+
* @returns {ModifiedJulianDate}
|
|
40
|
+
*/
|
|
41
|
+
static fromUtc(year, month, day, hour, minute, second) {
|
|
42
|
+
return new ModifiedJulianDate(backend.mjdFromUtc(year, month, day, hour, minute, second));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Raw MJD value. */
|
|
46
|
+
get value() {
|
|
47
|
+
return this._value;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The MJD value as a `Quantity` in Days. */
|
|
51
|
+
get days() {
|
|
52
|
+
return new Quantity(this._value, 'Day');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Convert to a `JulianDate`.
|
|
57
|
+
* @returns {import('./JulianDate.js').JulianDate}
|
|
58
|
+
*/
|
|
59
|
+
toJd() {
|
|
60
|
+
const { JulianDate } = require_jd();
|
|
61
|
+
return new JulianDate(backend.mjdToJd(this._value));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Convert to a JavaScript `Date` (UTC). */
|
|
65
|
+
toDate() {
|
|
66
|
+
return backend.mjdToDate(this._value);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Add a time duration (Quantity or number of days).
|
|
71
|
+
* @param {Quantity | number} duration
|
|
72
|
+
* @returns {ModifiedJulianDate}
|
|
73
|
+
*/
|
|
74
|
+
add(duration) {
|
|
75
|
+
return new ModifiedJulianDate(this._value + _toDays(duration));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Subtract a time duration.
|
|
80
|
+
* @param {Quantity | number} duration
|
|
81
|
+
* @returns {ModifiedJulianDate}
|
|
82
|
+
*/
|
|
83
|
+
sub(duration) {
|
|
84
|
+
return new ModifiedJulianDate(this._value - _toDays(duration));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Add a duration in days.
|
|
89
|
+
* @param {number} days
|
|
90
|
+
* @returns {ModifiedJulianDate}
|
|
91
|
+
* @deprecated Use `add()` instead.
|
|
92
|
+
*/
|
|
93
|
+
addDays(days) {
|
|
94
|
+
if (!Number.isFinite(days)) throw new Error('days must be finite');
|
|
95
|
+
return new ModifiedJulianDate(this._value + days);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Signed difference `self − other` as a Quantity in Days.
|
|
100
|
+
* @param {ModifiedJulianDate} other
|
|
101
|
+
* @returns {Quantity}
|
|
102
|
+
*/
|
|
103
|
+
difference(other) {
|
|
104
|
+
return new Quantity(this._value - other._value, 'Day');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Human-readable representation. */
|
|
108
|
+
format() {
|
|
109
|
+
return `MJD ${this._value} d`;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Deferred module reference for breaking circular import
|
|
114
|
+
let _jdModule = null;
|
|
115
|
+
function require_jd() {
|
|
116
|
+
if (!_jdModule) {
|
|
117
|
+
_jdModule = { JulianDate: null };
|
|
118
|
+
import('./JulianDate.js').then(m => { _jdModule.JulianDate = m.JulianDate; });
|
|
119
|
+
}
|
|
120
|
+
return _jdModule;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Eagerly resolve the deferred import
|
|
124
|
+
import('./JulianDate.js').then(m => {
|
|
125
|
+
_jdModule = { JulianDate: m.JulianDate };
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Convert a duration argument to days (number).
|
|
130
|
+
* @param {Quantity | number} d
|
|
131
|
+
* @returns {number}
|
|
132
|
+
*/
|
|
133
|
+
function _toDays(d) {
|
|
134
|
+
if (typeof d === 'number') {
|
|
135
|
+
if (!Number.isFinite(d)) throw new Error('Duration must be finite');
|
|
136
|
+
return d;
|
|
137
|
+
}
|
|
138
|
+
if (d && typeof d.value === 'number' && typeof d.unit === 'string') {
|
|
139
|
+
if (d.dimension !== 'Time') {
|
|
140
|
+
throw new Error(`Expected a time Quantity, got ${d.dimension}`);
|
|
141
|
+
}
|
|
142
|
+
return convert(d.value, d.unit, 'Day');
|
|
143
|
+
}
|
|
144
|
+
throw new Error('Expected a Quantity or number');
|
|
145
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @siderust/tempoch-web — Period façade class (ESM/browser).
|
|
3
|
+
*
|
|
4
|
+
* @module @siderust/tempoch-web/lib/Period
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Quantity } from '@siderust/qtty-web';
|
|
8
|
+
import { ModifiedJulianDate } from './ModifiedJulianDate.js';
|
|
9
|
+
import * as backend from './backend.js';
|
|
10
|
+
|
|
11
|
+
export class Period {
|
|
12
|
+
/**
|
|
13
|
+
* Create a period from two `ModifiedJulianDate` objects or raw MJD numbers.
|
|
14
|
+
* @param {ModifiedJulianDate | number} start
|
|
15
|
+
* @param {ModifiedJulianDate | number} end
|
|
16
|
+
*/
|
|
17
|
+
constructor(start, end) {
|
|
18
|
+
const startVal = typeof start === 'number' ? start : start._value;
|
|
19
|
+
const endVal = typeof end === 'number' ? end : end._value;
|
|
20
|
+
|
|
21
|
+
if (!Number.isFinite(startVal) || !Number.isFinite(endVal)) {
|
|
22
|
+
throw new Error('Period endpoints must be finite');
|
|
23
|
+
}
|
|
24
|
+
if (startVal > endVal) {
|
|
25
|
+
throw new Error('Period start must not be after end');
|
|
26
|
+
}
|
|
27
|
+
this._startMjd = startVal;
|
|
28
|
+
this._endMjd = endVal;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Create a period from two JavaScript `Date` objects.
|
|
33
|
+
* @param {Date} start
|
|
34
|
+
* @param {Date} end
|
|
35
|
+
* @returns {Period}
|
|
36
|
+
*/
|
|
37
|
+
static fromDates(start, end) {
|
|
38
|
+
const startMjd = backend.mjdFromDate(start);
|
|
39
|
+
const endMjd = backend.mjdFromDate(end);
|
|
40
|
+
if (startMjd > endMjd) {
|
|
41
|
+
throw new Error('Period start must not be after end');
|
|
42
|
+
}
|
|
43
|
+
return new Period(startMjd, endMjd);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Start of the period as a raw MJD value. */
|
|
47
|
+
get startMjd() {
|
|
48
|
+
return this._startMjd;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** End of the period as a raw MJD value. */
|
|
52
|
+
get endMjd() {
|
|
53
|
+
return this._endMjd;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Start as a `ModifiedJulianDate` object. */
|
|
57
|
+
get start() {
|
|
58
|
+
return new ModifiedJulianDate(this._startMjd);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** End as a `ModifiedJulianDate` object. */
|
|
62
|
+
get end() {
|
|
63
|
+
return new ModifiedJulianDate(this._endMjd);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Duration of the period as a `Quantity` in Days.
|
|
68
|
+
* @returns {Quantity}
|
|
69
|
+
*/
|
|
70
|
+
duration() {
|
|
71
|
+
return new Quantity(this._endMjd - this._startMjd, 'Day');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Duration of the period in days (raw number).
|
|
76
|
+
* @returns {number}
|
|
77
|
+
*/
|
|
78
|
+
durationDays() {
|
|
79
|
+
return this._endMjd - this._startMjd;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Return the overlapping sub-period, or `null` if they do not overlap.
|
|
84
|
+
* @param {Period} other
|
|
85
|
+
* @returns {Period | null}
|
|
86
|
+
*/
|
|
87
|
+
intersection(other) {
|
|
88
|
+
const s = Math.max(this._startMjd, other._startMjd);
|
|
89
|
+
const e = Math.min(this._endMjd, other._endMjd);
|
|
90
|
+
if (s >= e) return null;
|
|
91
|
+
return new Period(s, e);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Return `true` if the value falls inside `[start, end)`.
|
|
96
|
+
* @param {number | ModifiedJulianDate} mjd
|
|
97
|
+
* @returns {boolean}
|
|
98
|
+
*/
|
|
99
|
+
contains(mjd) {
|
|
100
|
+
const val = typeof mjd === 'number' ? mjd : mjd._value;
|
|
101
|
+
return val >= this._startMjd && val < this._endMjd;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Return start and end as millisecond timestamps.
|
|
106
|
+
* @returns {{ startMs: number, endMs: number }}
|
|
107
|
+
*/
|
|
108
|
+
toUtc() {
|
|
109
|
+
const startDate = backend.mjdToDate(this._startMjd);
|
|
110
|
+
const endDate = backend.mjdToDate(this._endMjd);
|
|
111
|
+
return {
|
|
112
|
+
startMs: startDate.getTime(),
|
|
113
|
+
endMs: endDate.getTime(),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Human-readable representation. */
|
|
118
|
+
format() {
|
|
119
|
+
return `Period(MJD ${this._startMjd.toFixed(6)} to MJD ${this._endMjd.toFixed(6)})`;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @siderust/tempoch-web — Internal WASM backend abstraction.
|
|
3
|
+
*
|
|
4
|
+
* Loads the wasm-bindgen generated module and re-exports the primitive
|
|
5
|
+
* free functions that the shared JS façade classes need.
|
|
6
|
+
*
|
|
7
|
+
* @module @siderust/tempoch-web/lib/backend
|
|
8
|
+
* @private
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
let wasm = null;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Initialise the WASM module. Must be called before any other function.
|
|
15
|
+
* @param {RequestInfo | URL | Response | BufferSource | WebAssembly.Module} [module_or_path]
|
|
16
|
+
*/
|
|
17
|
+
export async function init(module_or_path) {
|
|
18
|
+
const mod = await import('../pkg/tempoch_web.js');
|
|
19
|
+
await mod.default(module_or_path);
|
|
20
|
+
wasm = mod;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function ensureInit() {
|
|
24
|
+
if (!wasm) {
|
|
25
|
+
throw new Error('@siderust/tempoch-web: call init() before using any function');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// ── JD / MJD conversion ────────────────────────────────────────────
|
|
30
|
+
|
|
31
|
+
export function jdToMjd(jd) {
|
|
32
|
+
ensureInit();
|
|
33
|
+
return wasm.jdToMjd(jd);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function mjdToJd(mjd) {
|
|
37
|
+
ensureInit();
|
|
38
|
+
return wasm.mjdToJd(mjd);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ── Epoch-based quantities ─────────────────────────────────────────
|
|
42
|
+
|
|
43
|
+
export function julianCenturies(jd) {
|
|
44
|
+
ensureInit();
|
|
45
|
+
return wasm.julianCenturies(jd);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function julianYears(jd) {
|
|
49
|
+
ensureInit();
|
|
50
|
+
return wasm.julianYears(jd);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ── Date ↔ JD/MJD ─────────────────────────────────────────────────
|
|
54
|
+
// WASM can't access JS Date directly, so we pass millisecond
|
|
55
|
+
// timestamps and wrap/unwrap in the JS layer.
|
|
56
|
+
|
|
57
|
+
export function jdFromDate(date) {
|
|
58
|
+
ensureInit();
|
|
59
|
+
return wasm.jdFromMs(date.getTime());
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function mjdFromDate(date) {
|
|
63
|
+
ensureInit();
|
|
64
|
+
return wasm.mjdFromMs(date.getTime());
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function jdToDate(jd) {
|
|
68
|
+
ensureInit();
|
|
69
|
+
const ms = wasm.jdToMs(jd);
|
|
70
|
+
return new Date(ms);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function mjdToDate(mjd) {
|
|
74
|
+
ensureInit();
|
|
75
|
+
const ms = wasm.mjdToMs(mjd);
|
|
76
|
+
return new Date(ms);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ── UTC components → JD/MJD ───────────────────────────────────────
|
|
80
|
+
|
|
81
|
+
export function jdFromUtc(year, month, day, hour, minute, second) {
|
|
82
|
+
ensureInit();
|
|
83
|
+
return wasm.jdFromUtc(year, month, day, hour, minute, second);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function mjdFromUtc(year, month, day, hour, minute, second) {
|
|
87
|
+
ensureInit();
|
|
88
|
+
return wasm.mjdFromUtc(year, month, day, hour, minute, second);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// ── Arithmetic ────────────────────────────────────────────────────
|
|
92
|
+
|
|
93
|
+
export function jdAddDays(jd, days) {
|
|
94
|
+
ensureInit();
|
|
95
|
+
return wasm.jdAddDays(jd, days);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function mjdAddDays(mjd, days) {
|
|
99
|
+
ensureInit();
|
|
100
|
+
return wasm.mjdAddDays(mjd, days);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function jdDifference(jd1, jd2) {
|
|
104
|
+
ensureInit();
|
|
105
|
+
return wasm.jdDifference(jd1, jd2);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function mjdDifference(mjd1, mjd2) {
|
|
109
|
+
ensureInit();
|
|
110
|
+
return wasm.mjdDifference(mjd1, mjd2);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// ── Version ───────────────────────────────────────────────────────
|
|
114
|
+
|
|
115
|
+
export function version() {
|
|
116
|
+
ensureInit();
|
|
117
|
+
return wasm.version();
|
|
118
|
+
}
|