@johnmorrisdotca/wakusei-planets 0.19.0 → 0.20.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/CHANGELOG.md +10 -0
- package/NOTICE.md +5 -3
- package/README.md +8 -5
- package/dist/calendar.d.ts +119 -0
- package/dist/calendar.js +154 -0
- package/dist/clock.d.ts +244 -0
- package/dist/clock.js +326 -0
- package/dist/coordinates.d.ts +177 -0
- package/dist/coordinates.js +169 -0
- package/dist/data/lunar.d.ts +4 -0
- package/dist/data/lunar.js +548 -0
- package/dist/data/pluto.d.ts +6 -0
- package/dist/data/pluto.js +29 -0
- package/dist/data/tables.d.ts +41 -0
- package/dist/data/tables.js +37 -0
- package/dist/data/vsop.d.ts +19 -1
- package/dist/data/vsop.js +25 -8
- package/dist/element.d.ts +3 -2
- package/dist/element.js +1 -0
- package/dist/ephemeris.d.ts +3 -15
- package/dist/ephemeris.js +66 -49
- package/dist/mars.d.ts +41 -0
- package/dist/mars.js +52 -0
- package/dist/scales.d.ts +46 -0
- package/dist/scales.js +75 -0
- package/dist/sidereal.d.ts +66 -0
- package/dist/sidereal.js +88 -0
- package/dist/sky/engine.d.ts +46 -0
- package/dist/sky/engine.js +145 -0
- package/dist/sky/events.d.ts +37 -0
- package/dist/sky/events.js +133 -0
- package/dist/suncalc-legacy.d.ts +187 -0
- package/dist/suncalc-legacy.js +168 -0
- package/dist/suncalc.d.ts +209 -0
- package/dist/suncalc.js +173 -0
- package/dist/tables/all.d.ts +2 -0
- package/dist/tables/all.js +2 -0
- package/dist/tables/ceres.d.ts +1 -0
- package/dist/tables/ceres.js +57 -0
- package/dist/tables/dwarfs.d.ts +1 -0
- package/dist/tables/dwarfs.js +59 -0
- package/dist/theory.d.ts +20 -0
- package/dist/theory.js +98 -0
- package/dist/time.d.ts +6 -108
- package/dist/time.js +7 -180
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/when.d.ts +16 -0
- package/dist/when.js +18 -0
- package/package.json +45 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.20.0] - 2026-11-07
|
|
6
|
+
|
|
7
|
+
- **`/time` is the whole clock** (MODULES-538). The `julian` package's functions under the same names (`julian`, `toDate`, `toJulianDay`, `toMillisecondsInJulianDay`, `fromJulianDayAndMilliseconds`; julian truncates toward zero before 31 December 1969 and gives a day one too high, these floor); `julianCenturies`, `julianMillennia` and the epochs (`J2000_JD`, `J2000_MS`, `B1950_JD`); the Gregorian and Julian calendars (`toCalendar`, `fromCalendar`, `dayOfWeek`, `dayOfYear`, `daysInMonth`, `isLeapYear`, the switch of 1582, astronomical years, the whole range of a Date); time scales UTC, UT1, TAI, GPS, TT and TDB (`convertTimeScale`, `taiMinusUtc`, `deltaT`, `tdbMinusTt`) with the leap seconds from 1972; sidereal time (`greenwichMeanSiderealTime`, `greenwichApparentSiderealTime`, `localSiderealTime`, `equationOfTheEquinoxes`); and Mars time (`marsSolDate`, `coordinatedMarsTime`, `marsLocalMeanSolarTime`). Every function takes a `Date` or milliseconds, never changes a `Date` and throws on an invalid one. About 3 kB gzipped, no dependencies. Tests: Meeus's worked examples (chapters 7 and 12), the julian package and astronomy-engine as dev-only oracles, round trips over the years -5000 to 5000 and the ends of a Date, every pair of time scales from 1800 to 2200. EN/JA guide `docs/guides/time.md`.
|
|
8
|
+
- Add a reproducible, development-only accuracy comparison against JPL Horizons for wakusei, Astronomy Engine, Python solarsystem and SunCalc 2.1.2, with EN/JA tables, pinned dependencies, source provenance and frozen regression limits (MODULES-556). Astronomy Engine wins Earth and the four Galilean moons on the shared modern grid; no blanket superiority is claimed.
|
|
9
|
+
- **`/suncalc`: the Sun and Moon from a place, a drop-in for suncalc 2** (MODULES-535). `getPosition`, `getTimes`, `addTime`, `times`, `getMoonPosition`, `getMoonIllumination` and `getMoonTimes` with suncalc 2's names, arguments and results (degrees, azimuth from north, `utcOffset`, observer height, Moon transits), on this package's own VSOP87B Sun and ELP2000-82B Moon with precession, nutation, aberration, parallax and refraction. Sunrise and sunset are within 7 seconds of astronomy-engine and moonrise within 1 (suncalc is 13 and 5); the tests compare against suncalc 2.1.2, suncalc 1.9.0 and astronomy-engine as dev-only oracles. `/suncalc/legacy` has suncalc 1's conventions (radians, azimuth from south, invalid dates, `inUTC`) so only the import changes. Both are 10 kB gzipped: the Earth's VSOP87B series now has its own export (`VSOP_EARTH`) so a page needs one planet, and the two theories moved to `src/theory.ts`. EN/JA guide. Planets' rise and set, eclipses and suncalc3's extras are not here yet (MODULES-537).
|
|
10
|
+
- **The Moon is ELP2000-82B, within 2 arc-seconds of Horizons** (MODULES-528). The Moon was the largest terms of a short series and 0.21 degrees (760 arc-seconds) from Horizons; it is now the lunar solution ELP2000-82B (Chapront-Touzé and Chapront, IMCCE) cut to its 540 largest terms (of 37,872), in terrestrial time, with the constants fitted to JPL's DE200 folded in (`scripts/make-lunar-data.py`, `src/data/lunar.ts`; the core entry point grows from 39.3 to 44.7 kB gzipped). The worst of seven dates from 1900 to 2100 is 1.8 arc-seconds and the distance is within 0.8 km; the limit in `test/accuracy.test.ts` falls from 0.3 degrees to 0.0008. The phase, rise and set of the Moon follow from the better position.
|
|
11
|
+
- **The dwarf planets are fitted to Horizons** (MODULES-554, 557). Ceres was 9 degrees from Horizons in 1900 and 2 degrees in 2000, and Orcus, Haumea, Quaoar, Makemake, Gonggong, Eris and Sedna a few arc-minutes, because each was one ellipse of one epoch. Each is now a Chebyshev table from the solar system's barycentre (`scripts/make-dwarf-data.py`), with the Sun's twelve-year swing about the barycentre added back from the planets' masses; all eight are within 0.2 arc-seconds of Horizons on dates off the fit's grid (Ceres 1900 to 2100, the others 1800 to 2200). `test/accuracy.test.ts` holds each to a limit, `test/pluto.test.ts` checks the segment edges, and the tables load on demand (MODULES-557): `@johnmorrisdotca/wakusei-planets/tables/dwarfs` (about 5 kB gzipped), `/tables/ceres` (about 14 kB) and `/tables` for both register themselves, the web component imports them, and `heliocentric` without them still answers with the old elements, so the core entry point stays at 39.0 kB gzipped.
|
|
12
|
+
- **Pluto is fitted to Horizons** (MODULES-528). VSOP87 has no Pluto, and JPL's approximate elements were 39 arc-seconds from Horizons; a table of 20 Chebyshev segments of 20 years (1800 to 2200, `scripts/make-pluto-data.py`, `src/data/pluto.ts`) is 0.05 arc-seconds on the five reference dates and 0.15 at worst on samples held back from the fit. Pluto is no longer the loosest planet; Saturn and Uranus (3.7 and 3.8) are. The segments are fitted on their own, so the position can step by up to 0.15 arc-seconds where one ends (tested). The elements still answer outside 1800 to 2200. The remaining error is the Sun's yearly wobble about the system's centre of mass, 0.016 arc-seconds at Pluto's distance, which a polynomial of this size cannot follow. The core entry point grows from 35.1 to 39.0 kB gzipped.
|
|
13
|
+
- Add the pure `/coordinates` sub-path: spherical/Cartesian AU coordinates, mean ecliptic/equatorial rotations at J2000 or of date, and equatorial-of-date to horizontal directions. Explicit origins, frames and epochs, degree angles, EN/JA guides, Meeus known-answer tests and a 4 KiB gzip budget (MODULES-555).
|
|
14
|
+
|
|
5
15
|
## 0.19.0 - 2026-11-07
|
|
6
16
|
|
|
7
17
|
The planets and the moons are where they are, and every body is checked against JPL Horizons (MODULES-528, 525, 522). 0.18.0 was never published: what it holds, the view gestures, is below and is in this release.
|
package/NOTICE.md
CHANGED
|
@@ -9,16 +9,18 @@ No picture is used by the line and shaded looks: they are drawn from numbers.
|
|
|
9
9
|
- **Sizes, flattening, axial tilt, poles and rotation**: the IAU Working Group on Cartographic Coordinates and Rotational Elements, B. A. Archinal et al. (2018), "Report of the IAU Working Group on Cartographic Coordinates and Rotational Elements: 2015", Celestial Mechanics and Dynamical Astronomy 130:22, and NASA's planetary and satellite fact sheets (https://nssdc.gsfc.nasa.gov/planetary/factsheet/, read 2026-11-02). Facts are not copyrightable; the values were typed from these sources.
|
|
10
10
|
- **Mercury to Neptune**: the VSOP87B series, P. Bretagnon and G. Francou (1988), "Planetary theories in rectangular and spherical variables: VSOP87 solutions", Astronomy and Astrophysics 202, 309, from the files of IMCCE, Observatoire de Paris (https://ftp.imcce.fr/pub/ephem/planets/vsop87/, read 2026-11-07), cut to 991 of 35,080 terms into `src/data/vsop.ts` by `scripts/make-vsop-data.py`. The files state their precision and ask to be cited; they carry no licence text, and the numbers are a published scientific table.
|
|
11
11
|
- **Time scales**: the leap seconds are IERS Bulletin C; delta T before 1972 is the polynomials of F. Espenak and J. Meeus (NASA, https://eclipse.gsfc.nasa.gov/SEhelp/deltatpoly2004.html), in `src/time.ts`.
|
|
12
|
-
- **
|
|
12
|
+
- **Calendars, sidereal time and Mars time (`/time`)**: written here from J. Meeus, "Astronomical Algorithms" (2nd edition, chapters 7 and 12: the Julian day and the sidereal time), the Richards day-number algorithm for the calendars, M. Allison and M. McEwen, "A post-Pathfinder evaluation of aerocentric solar coordinates with improved timing recipes for Mars seasonal/diurnal climate studies", Planetary and Space Science 48, 215 (2000), and Meeus's two-term formula for TDB minus TT. The names of the Julian-date functions follow the `julian` package (MIT, Stepan Stolyarov), whose code is not used; `julian` 0.2.0 and astronomy-engine are development-time comparisons in `test/calendar.test.ts` only and are not shipped.
|
|
13
|
+
- **Pluto's position**: a Chebyshev table (`src/data/pluto.ts`, made by `scripts/make-pluto-data.py`) fitted to JPL Horizons (https://ssd.jpl.nasa.gov/api/horizons.api, read 2026-11-07), 1800 to 2200; outside those years, and for its earlier edition, JPL Solar System Dynamics, "Keplerian Elements for Approximate Positions of the Major Planets", Table 1, 1800 AD to 2050 AD (https://ssd.jpl.nasa.gov/planets/approx_pos.html, read 2026-11-02; Pluto from the same page's earlier edition). NASA/JPL content is not subject to copyright in the United States; credit: NASA/JPL-Caltech.
|
|
13
14
|
- **Moons' orbits**: fitted to the positions and velocities of JPL Horizons (https://ssd.jpl.nasa.gov/api/horizons.api, read 2026-11-07) for 1950 to 2050, by `scripts/make-moon-data.py`, which writes `src/data/orbits.ts`; the Moon's row, and the pole of each moon's reference plane, are from JPL Solar System Dynamics, "Planetary Satellite Mean Elements" (https://ssd.jpl.nasa.gov/sats/elem/, read 2026-11-02). The positions the accuracy test compares with are in `test/data/horizons.json`, fetched by `scripts/fetch-horizons-reference.py`. Credit: NASA/JPL-Caltech; the satellite ephemerides behind Horizons are R. A. Jacobson and colleagues' (the page names each).
|
|
14
|
-
- **The Moon's position**: the
|
|
15
|
+
- **The Moon's position**: the lunar solution ELP2000-82B, M. Chapront-Touzé and J. Chapront, "The lunar ephemeris ELP 2000", Astron. Astrophys. 124, 50 (1983) and "ELP 2000-85", Astron. Astrophys. 190, 342 (1988), from IMCCE, Observatoire de Paris (https://ftp.imcce.fr/pub/ephem/moon/elp82b/). Its 37,872 terms are cut to the 540 above 0.05 arc-seconds (`scripts/make-lunar-data.py`, `src/data/lunar.ts`) and written out as numbers, with the constants fitted to JPL's DE200 that the notice gives. IMCCE's files carry no licence text; they are published for use with the credit above (the same footing as VSOP87).
|
|
16
|
+
- **Sun and Moon times (`/suncalc`)**: written here from the standard methods: J. Meeus, "Astronomical Algorithms" (2nd edition, chapters 11, 12, 21, 22, 48), the IAU 1976 precession, the IAU 1980 nutation (its largest terms), Saemundsson's refraction formula, and the Naval Observatory's convention for the rise and set of the Moon and Sun. The names, arguments and results follow the public interface of suncalc (BSD-2-Clause, Copyright (c) Volodymyr Agafonkin; https://github.com/mourner/suncalc), whose code is not used. suncalc 1.9.0 and 2.1.2 and astronomy-engine (MIT) are development-time comparisons in `test/suncalc.test.ts` only and are not shipped.
|
|
15
17
|
- **Mass and escape speed** (`JOURNEY_STOPS`): JPL "Planetary Satellite Physical Parameters" (https://ssd.jpl.nasa.gov/sats/phys_par/, read 2026-11-04) for the GM of the Earth, Mars through Pluto and the moons on that page; NASA's Sun, Mercury and Venus fact sheets (https://nssdc.gsfc.nasa.gov/planetary/factsheet/, read 2026-11-04) for those three GM values and the Sun's escape speed; JPL "Planetary Physical Parameters" (https://ssd.jpl.nasa.gov/planets/phys_par.html, read 2026-11-04) for the planets' escape speeds and for the masses of Ceres, Eris, Makemake and Haumea, turned into GM with the CODATA 2018 G that page names. A moon's escape speed is computed from its GM and the radius already in this package. Nereid, Orcus, Quaoar, Gonggong, Sedna, Vanth, Hiʻiaka, Namaka and Dysnomia are left blank: those pages do not print a mass.
|
|
16
18
|
|
|
17
19
|
## The dwarf planets
|
|
18
20
|
|
|
19
21
|
Ceres, Orcus, Haumea, Quaoar, Makemake, Gonggong, Eris and Sedna (Pluto is with the planets) and the moons Vanth, Hiʻiaka, Namaka and Dysnomia. Values read on 2026-11-03.
|
|
20
22
|
|
|
21
|
-
- **Where they are**: NASA/JPL Small-Body Database
|
|
23
|
+
- **Where they are**: JPL Horizons (https://ssd.jpl.nasa.gov/api/horizons.api), fitted as Chebyshev tables from the solar system's barycentre (`scripts/make-dwarf-data.py`, `src/data/dwarfs.ts`), with the Sun's swing about the barycentre worked out from the planets' masses (IAU 2012 and JPL DE440 mass ratios): Ceres 1900 to 2100, the others 1800 to 2200, each within 0.2 arc-seconds of Horizons. Outside those years, NASA/JPL Small-Body Database osculating elements at JD 2461200.5 (https://ssd.jpl.nasa.gov/api/sbdb.api), run as a plain ellipse (`src/data/dwarf.ts`): good for a few years either side of June 2026.
|
|
22
24
|
- **Sizes and spin**: Ceres (966.2 x 962.0 x 891.8 km) and its pole: Ermakov et al. 2017 (as listed in Wikipedia's Ceres article); its rotation: JPL SBDB (9.074170 h). Haumea: Ortiz et al. 2017, Nature 550:219 (semi-axes 1161 x 852 x 513 km), rotation 3.915341 h from Santos-Sanz et al. 2017, A&A 604:A95, pole from Kondratyev & Kornoukhov 2018, MNRAS 478:3159 (RA 282.6, Dec -13.0). Eris: radius 1163 km, Sicardy et al. 2011; it keeps one face to Dysnomia, so its rotation is Dysnomia's orbital period, Szakats et al. 2023, A&A 669:L3. Makemake: radius 715 km, Brown 2013; rotation 22.8266 h, Hromakina et al. 2019. Gonggong: radius 615 km and rotation 22.4 h, Kiss et al. 2019, Icarus. Quaoar: 1241.4 x 1093.0 x 1023.0 km and 17.6788 h, Margoti et al. 2026 and Pereira et al. 2023. Sedna: radius 453 km (Lellouch et al. 2013, TNOs are Cool IX, which allows far more) and 10.273 h, Gaudi et al. 2005. Orcus: radius 455 km, Brown & Butler 2018, rotation 13.188 h (JPL SBDB; 7 to 21 h in the literature). Wikipedia's articles on each body were the finding aid; the papers are the sources.
|
|
23
25
|
- **Moons' orbits**: Dysnomia, Holler et al. 2021, Icarus 355:114130, Table 2 (arXiv 2009.13733). Hiʻiaka and Namaka, Ragozzine & Brown 2009, AJ 137:4766, Table 2 (osculating elements of 2008; the two moons pull on each other, so the position years later is rough). Vanth, Brown et al. 2010, AJ 139:2700, Table 2, solution 1 of two mirror solutions. Radii: Dysnomia 308 km (Brown & Butler 2023), Vanth 221 km (Sickafoose et al. 2018, occultation), Hiʻiaka and Namaka from the Haumea article's listed diameters (370 and 150 km). Weywot, Xiangliu and Makemake's moon S/2015 (136472) 1 are left out: no orbit with a published phase.
|
|
24
26
|
- **Estimated, not measured** (the pictures say so only here): these bodies' poles are not measured, so each is drawn with its spin axis along its orbit's pole (Quaoar, Makemake, Gonggong, Sedna), along Dysnomia's orbit pole (Eris) or along the far end of Vanth's orbit pole, so that it spins forwards (Orcus). Hiʻiaka's and Namaka's spin is unknown and they are drawn still. Dysnomia and Vanth are assumed to keep one face to their planet. Every drawn feature on the line look of a dwarf planet except Ceres's Occator crater and Haumea's long axis is a generic crater, and so is each shaded (realistic) look: only the colour (from the published colour indices and albedos) and the sizes are from numbers. Ceres, Haumea and Dysnomia's shapes are from the sources above. Only Ceres has a painted look.
|
package/README.md
CHANGED
|
@@ -13,9 +13,9 @@ A clean line drawing, a shaded realistic drawing, or a painted surface map, with
|
|
|
13
13
|
|
|
14
14
|
<p align="center"><a href="https://johnmorrisdotca.github.io/wakusei-planets/"><strong>Open the demo →</strong></a> · <a href="https://johnmorrisdotca.github.io/wakusei-planets/embed.html">Embed page</a> · <a href="https://johnmorrisdotca.github.io/wakusei-planets/docs/">Docs</a></p>
|
|
15
15
|
|
|
16
|
-
<p align="center"><img alt="Jupiter and Saturn drawn in the realistic look, and Saturn as a line drawing" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.
|
|
16
|
+
<p align="center"><img alt="Jupiter and Saturn drawn in the realistic look, and Saturn as a line drawing" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.20.0/docs/images/hero-desk.png" width="640"></p>
|
|
17
17
|
|
|
18
|
-
<p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.
|
|
18
|
+
<p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.20.0/docs/images/lineup-desk.png" width="640"></p>
|
|
19
19
|
|
|
20
20
|
## One minute
|
|
21
21
|
|
|
@@ -176,7 +176,7 @@ The pure side has no DOM: `BODIES`, `apparent(id, time)`, `system(planet, time)`
|
|
|
176
176
|
|
|
177
177
|
## The data
|
|
178
178
|
|
|
179
|
-
Sizes, flattening, poles and rotation are the IAU's and NASA's; Mercury to Neptune are VSOP87B, cut down, and Pluto is
|
|
179
|
+
Sizes, flattening, poles and rotation are the IAU's and NASA's; Mercury to Neptune are VSOP87B, cut down, and Pluto is a table fitted to Horizons; the Moon's are the lunar solution ELP2000-82B cut down; the other moons are fitted to JPL Horizons' positions, and every body is tested against Horizons ([accuracy](docs/guides/accuracy.md)). Nothing is fetched at run time by the line and shaded looks, which use no pictures. See [NOTICE.md](NOTICE.md).
|
|
180
180
|
|
|
181
181
|
## Examples
|
|
182
182
|
|
|
@@ -273,7 +273,7 @@ A body that turns by itself and a moving sky, in HTML:
|
|
|
273
273
|
|
|
274
274
|
## The portrait builder
|
|
275
275
|
|
|
276
|
-
<p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.
|
|
276
|
+
<p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.20.0/docs/images/portrait-family.png" width="640"></p>
|
|
277
277
|
|
|
278
278
|
[The portrait builder](https://johnmorrisdotca.github.io/wakusei-planets/portrait.html) puts any bodies in one picture: drag them, size them, turn them, order them front to back, arrange them in a row, an arc, a grid or at true orbit distance (true or readable sizes, a planet's moons round it in orbit order), light them from one direction, and take the code, a PNG or an SVG. The scene is kept in the address, and every body is drawn in one WebGL scene, so the page holds one WebGL context. [The portrait builder](docs/guides/portrait-builder.md) is its guide.
|
|
279
279
|
|
|
@@ -321,6 +321,9 @@ Each guide has a Japanese twin in [docs/guides/ja](docs/guides/ja/getting-starte
|
|
|
321
321
|
| [Moons and time](docs/guides/moons-and-time.md) | The sky on a date, time that runs fast |
|
|
322
322
|
| [Accuracy](docs/guides/accuracy.md) | How far each body is from JPL Horizons |
|
|
323
323
|
| [In your own three.js scene](docs/guides/in-your-own-scene.md) | `painter.make` |
|
|
324
|
+
| [Time](docs/guides/time.md) | Julian dates, calendars, time scales, sidereal time, Mars time |
|
|
325
|
+
| [The Sun and Moon from a place](docs/guides/suncalc.md) | Position, sunrise and sunset, Moon rise, set and phase; a drop-in for suncalc |
|
|
326
|
+
| [Coordinate conversions](docs/guides/coordinates.md) | Pure spherical, ecliptic, equatorial and horizontal coordinate conversions |
|
|
324
327
|
| [TypeScript and Node](docs/guides/typescript-and-node.md) | Types and the pure side |
|
|
325
328
|
| [How it works](docs/guides/how-it-works.md) | Where the numbers come from |
|
|
326
329
|
| [Architecture](docs/guides/architecture.md) | How the layers fit |
|
|
@@ -335,7 +338,7 @@ import { BODIES } from "@johnmorrisdotca/wakusei-planets";
|
|
|
335
338
|
BODIES.pluto.kind; // "dwarf-planet"
|
|
336
339
|
```
|
|
337
340
|
|
|
338
|
-
- A fact with no source is left out, never guessed. Moon positions are fitted to
|
|
341
|
+
- A fact with no source is left out, never guessed. The Moon is within 2 arc-seconds of JPL Horizons, and the other moons' positions are fitted to it and are within a degree or two on the orbit for almost every moon, about the size of the moon on screen; [accuracy](docs/guides/accuracy.md) has each body's number.
|
|
339
342
|
- `realistic` and `painted` are the photo maps (`painted` is the same maps, so an older page still works). `illustrated` is the shaded drawing from the numbers, and it is not a default. Venus, Saturn, Neptune and the Sun use Solar System Scope's maps (CC BY 4.0). Mercury uses the natural grey 8K map (Shady Tex and Solar System Scope, CC BY 4.0). Mars stays on the Viking mosaic, graded toward a butterscotch ochre, with the frost in Hellas toned to the basin and the polar ice left. Jupiter and Uranus use Nestaeric's maps (CC BY 4.0), and Saturn's poles use Nestaeric's caps (CC BY 4.0). The Earth and the Moon stay on their NASA maps until those have been compared. The rest are the public-domain maps in `NOTICE.md`.
|
|
340
343
|
- A shaded look needs WebGL. Without it the line drawing is drawn.
|
|
341
344
|
- Jupiter, Saturn, Uranus and Neptune have their rings drawn.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { type When } from "./when.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Which calendar: `gregorian` and `julian` are used for every year (the proleptic calendars), and `auto` follows history: the Julian calendar to 1582-10-04 and the Gregorian from 1582-10-15.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { type Calendar } from "@johnmorrisdotca/wakusei-planets/time";
|
|
8
|
+
*
|
|
9
|
+
* const calendar: Calendar = "auto";
|
|
10
|
+
* console.log(calendar);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export type Calendar = "gregorian" | "julian" | "auto";
|
|
14
|
+
/**
|
|
15
|
+
* A date and time of day. The year is astronomical (1 BCE is 0, 2 BCE is -1), the month is 1 to 12, the day starts at 1.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { toCalendar, type CivilTime } from "@johnmorrisdotca/wakusei-planets/time";
|
|
20
|
+
*
|
|
21
|
+
* const t: CivilTime = toCalendar(Date.UTC(1957, 9, 4, 19, 26, 24));
|
|
22
|
+
* console.log(t.year, t.month, t.day, t.hour);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export interface CivilTime {
|
|
26
|
+
year: number;
|
|
27
|
+
month: number;
|
|
28
|
+
day: number;
|
|
29
|
+
hour: number;
|
|
30
|
+
minute: number;
|
|
31
|
+
second: number;
|
|
32
|
+
millisecond: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether a year is a leap year.
|
|
36
|
+
* @param year - The astronomical year.
|
|
37
|
+
* @param calendar - `gregorian` (a century is a leap year only if divisible by 400), `julian` (every fourth year), or `auto` (the Julian rule to 1582, the Gregorian after).
|
|
38
|
+
* @returns `true` for a leap year.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { isLeapYear } from "@johnmorrisdotca/wakusei-planets/time";
|
|
43
|
+
*
|
|
44
|
+
* console.log(isLeapYear(1900), isLeapYear(1900, "julian"), isLeapYear(2000));
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function isLeapYear(year: number, calendar?: Calendar): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* The number of days in a month; October 1582 has 21 in the `auto` calendar, the ten days of the switch being left out.
|
|
50
|
+
* @param year - The astronomical year.
|
|
51
|
+
* @param month - 1 to 12.
|
|
52
|
+
* @param calendar - `gregorian`, `julian` or `auto`.
|
|
53
|
+
* @returns The days in the month.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { daysInMonth } from "@johnmorrisdotca/wakusei-planets/time";
|
|
58
|
+
*
|
|
59
|
+
* console.log(daysInMonth(2024, 2), daysInMonth(1582, 10));
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function daysInMonth(year: number, month: number, calendar?: Calendar): number;
|
|
63
|
+
/**
|
|
64
|
+
* A moment as a date and time of day in UTC, in the Gregorian or the Julian calendar.
|
|
65
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
66
|
+
* @param calendar - `auto` (default: the calendar in use that day), `gregorian` or `julian` for every year.
|
|
67
|
+
* @returns The year (astronomical), month, day, hour, minute, second and millisecond.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* import { toCalendar } from "@johnmorrisdotca/wakusei-planets/time";
|
|
72
|
+
*
|
|
73
|
+
* console.log(toCalendar(Date.UTC(1582, 9, 15)), toCalendar(Date.UTC(1582, 9, 15), "julian").day);
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function toCalendar(when: When, calendar?: Calendar): CivilTime;
|
|
77
|
+
/**
|
|
78
|
+
* A date and time of day in UTC as a moment, in milliseconds since 1970. A day that does not exist (31 April, 29 February in a common year, or 5 to 14 October 1582 in the `auto` calendar) throws a `RangeError`.
|
|
79
|
+
* @param civil - The year (astronomical), and the month (1), day (1), hour, minute, second and millisecond (0) when left out.
|
|
80
|
+
* @param calendar - `auto` (default), `gregorian` or `julian`.
|
|
81
|
+
* @returns Milliseconds since 1970.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* import { fromCalendar } from "@johnmorrisdotca/wakusei-planets/time";
|
|
86
|
+
*
|
|
87
|
+
* console.log(fromCalendar({ year: 333, month: 1, day: 27, hour: 12 }, "julian"), new Date(fromCalendar({ year: 2000, month: 1, day: 1, hour: 12 })).toISOString());
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function fromCalendar(civil: {
|
|
91
|
+
year: number;
|
|
92
|
+
} & Partial<Omit<CivilTime, "year">>, calendar?: Calendar): number;
|
|
93
|
+
/**
|
|
94
|
+
* The day of the week of a moment in UTC: 0 Sunday to 6 Saturday.
|
|
95
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
96
|
+
* @returns 0 to 6.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* import { dayOfWeek } from "@johnmorrisdotca/wakusei-planets/time";
|
|
101
|
+
*
|
|
102
|
+
* console.log(dayOfWeek(Date.UTC(1954, 5, 30)));
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare function dayOfWeek(when: When): number;
|
|
106
|
+
/**
|
|
107
|
+
* The day of the year of a moment in UTC: 1 on 1 January.
|
|
108
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
109
|
+
* @param calendar - `auto` (default), `gregorian` or `julian`.
|
|
110
|
+
* @returns 1 to 366.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* import { dayOfYear } from "@johnmorrisdotca/wakusei-planets/time";
|
|
115
|
+
*
|
|
116
|
+
* console.log(dayOfYear(Date.UTC(1978, 10, 14)), dayOfYear(Date.UTC(1988, 3, 22)));
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function dayOfYear(when: When, calendar?: Calendar): number;
|
package/dist/calendar.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// Calendars: the Gregorian and the Julian, the switch between them in October 1582, years before 1 CE (astronomical numbering, so the year 0 is 1 BCE), days of the week and of the year.
|
|
2
|
+
// Whole days are counted as integers, so a date goes to a moment and back without a digit lost and years from -271821 to 275760 (the range of a JavaScript `Date`) all work. Pure: no DOM, no three.js.
|
|
3
|
+
import { moment } from "./when.js";
|
|
4
|
+
const DAY_MS = 86_400_000;
|
|
5
|
+
/** The Julian day number (the day that begins at midnight) of 1970-01-01. */
|
|
6
|
+
const UNIX_DAY_NUMBER = 2_440_588;
|
|
7
|
+
/** The Julian day number of 1582-10-15, the first day of the Gregorian calendar. */
|
|
8
|
+
const REFORM_DAY_NUMBER = 2_299_161;
|
|
9
|
+
const floorMod = (a, b) => a - b * Math.floor(a / b);
|
|
10
|
+
function dayNumberOf(year, month, day, gregorian) {
|
|
11
|
+
const a = Math.floor((14 - month) / 12);
|
|
12
|
+
const y = year + 4800 - a;
|
|
13
|
+
const m = month + 12 * a - 3;
|
|
14
|
+
const base = day + Math.floor((153 * m + 2) / 5) + 365 * y + Math.floor(y / 4);
|
|
15
|
+
return gregorian ? base - Math.floor(y / 100) + Math.floor(y / 400) - 32045 : base - 32083;
|
|
16
|
+
}
|
|
17
|
+
function dateOfDayNumber(J, gregorian) {
|
|
18
|
+
const f = gregorian ? J + 1401 + Math.floor((Math.floor((4 * J + 274277) / 146097) * 3) / 4) - 38 : J + 1401;
|
|
19
|
+
const e = 4 * f + 3;
|
|
20
|
+
const g = Math.floor(floorMod(e, 1461) / 4);
|
|
21
|
+
const h = 5 * g + 2;
|
|
22
|
+
const day = Math.floor(floorMod(h, 153) / 5) + 1;
|
|
23
|
+
const month = ((Math.floor(h / 153) + 2) % 12) + 1;
|
|
24
|
+
return { year: Math.floor(e / 1461) - 4716 + Math.floor((14 - month) / 12), month, day };
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Whether a year is a leap year.
|
|
28
|
+
* @param year - The astronomical year.
|
|
29
|
+
* @param calendar - `gregorian` (a century is a leap year only if divisible by 400), `julian` (every fourth year), or `auto` (the Julian rule to 1582, the Gregorian after).
|
|
30
|
+
* @returns `true` for a leap year.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { isLeapYear } from "@johnmorrisdotca/wakusei-planets/time";
|
|
35
|
+
*
|
|
36
|
+
* console.log(isLeapYear(1900), isLeapYear(1900, "julian"), isLeapYear(2000));
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export function isLeapYear(year, calendar = "auto") {
|
|
40
|
+
if (!Number.isInteger(year))
|
|
41
|
+
throw new RangeError(`year must be a whole number, got ${year}`);
|
|
42
|
+
const gregorian = calendar === "gregorian" || (calendar === "auto" && year > 1582);
|
|
43
|
+
return floorMod(year, 4) === 0 && (!gregorian || floorMod(year, 100) !== 0 || floorMod(year, 400) === 0);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The number of days in a month; October 1582 has 21 in the `auto` calendar, the ten days of the switch being left out.
|
|
47
|
+
* @param year - The astronomical year.
|
|
48
|
+
* @param month - 1 to 12.
|
|
49
|
+
* @param calendar - `gregorian`, `julian` or `auto`.
|
|
50
|
+
* @returns The days in the month.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* import { daysInMonth } from "@johnmorrisdotca/wakusei-planets/time";
|
|
55
|
+
*
|
|
56
|
+
* console.log(daysInMonth(2024, 2), daysInMonth(1582, 10));
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export function daysInMonth(year, month, calendar = "auto") {
|
|
60
|
+
if (!Number.isInteger(month) || month < 1 || month > 12)
|
|
61
|
+
throw new RangeError(`month must be a whole number from 1 to 12, got ${month}`);
|
|
62
|
+
if (calendar === "auto" && year === 1582 && month === 10)
|
|
63
|
+
return 21;
|
|
64
|
+
if (month === 2)
|
|
65
|
+
return isLeapYear(year, calendar) ? 29 : 28;
|
|
66
|
+
return [4, 6, 9, 11].includes(month) ? 30 : 31;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A moment as a date and time of day in UTC, in the Gregorian or the Julian calendar.
|
|
70
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
71
|
+
* @param calendar - `auto` (default: the calendar in use that day), `gregorian` or `julian` for every year.
|
|
72
|
+
* @returns The year (astronomical), month, day, hour, minute, second and millisecond.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { toCalendar } from "@johnmorrisdotca/wakusei-planets/time";
|
|
77
|
+
*
|
|
78
|
+
* console.log(toCalendar(Date.UTC(1582, 9, 15)), toCalendar(Date.UTC(1582, 9, 15), "julian").day);
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export function toCalendar(when, calendar = "auto") {
|
|
82
|
+
const ms = Math.floor(moment(when));
|
|
83
|
+
const dayNumber = Math.floor(ms / DAY_MS) + UNIX_DAY_NUMBER;
|
|
84
|
+
const inDay = floorMod(ms, DAY_MS);
|
|
85
|
+
const gregorian = calendar === "gregorian" || (calendar === "auto" && dayNumber >= REFORM_DAY_NUMBER);
|
|
86
|
+
const { year, month, day } = dateOfDayNumber(dayNumber, gregorian);
|
|
87
|
+
return { year, month, day, hour: Math.floor(inDay / 3_600_000), minute: Math.floor((inDay % 3_600_000) / 60_000), second: Math.floor((inDay % 60_000) / 1000), millisecond: inDay % 1000 };
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* A date and time of day in UTC as a moment, in milliseconds since 1970. A day that does not exist (31 April, 29 February in a common year, or 5 to 14 October 1582 in the `auto` calendar) throws a `RangeError`.
|
|
91
|
+
* @param civil - The year (astronomical), and the month (1), day (1), hour, minute, second and millisecond (0) when left out.
|
|
92
|
+
* @param calendar - `auto` (default), `gregorian` or `julian`.
|
|
93
|
+
* @returns Milliseconds since 1970.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* import { fromCalendar } from "@johnmorrisdotca/wakusei-planets/time";
|
|
98
|
+
*
|
|
99
|
+
* console.log(fromCalendar({ year: 333, month: 1, day: 27, hour: 12 }, "julian"), new Date(fromCalendar({ year: 2000, month: 1, day: 1, hour: 12 })).toISOString());
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export function fromCalendar(civil, calendar = "auto") {
|
|
103
|
+
const { year, month = 1, day = 1, hour = 0, minute = 0, second = 0, millisecond = 0 } = civil;
|
|
104
|
+
for (const [name, value] of Object.entries({ year, month, day, hour, minute, second, millisecond }))
|
|
105
|
+
if (!Number.isInteger(value))
|
|
106
|
+
throw new RangeError(`${name} must be a whole number, got ${value}`);
|
|
107
|
+
if (hour < 0 || hour > 23 || minute < 0 || minute > 59 || second < 0 || second > 59 || millisecond < 0 || millisecond > 999)
|
|
108
|
+
throw new RangeError(`the time of day ${hour}:${minute}:${second}.${millisecond} does not exist`);
|
|
109
|
+
if (day < 1 || day > daysInMonth(year, month, calendar))
|
|
110
|
+
throw new RangeError(`${year}-${month}-${day} does not exist in the ${calendar} calendar`);
|
|
111
|
+
let gregorian = calendar === "gregorian";
|
|
112
|
+
if (calendar === "auto") {
|
|
113
|
+
const afterReform = year > 1582 || (year === 1582 && (month > 10 || (month === 10 && day >= 15)));
|
|
114
|
+
if (year === 1582 && month === 10 && day > 4 && day < 15)
|
|
115
|
+
throw new RangeError(`${year}-${month}-${day} does not exist: the calendar skipped 5 to 14 October 1582`);
|
|
116
|
+
gregorian = afterReform;
|
|
117
|
+
}
|
|
118
|
+
return (dayNumberOf(year, month, day, gregorian) - UNIX_DAY_NUMBER) * DAY_MS + hour * 3_600_000 + minute * 60_000 + second * 1000 + millisecond;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The day of the week of a moment in UTC: 0 Sunday to 6 Saturday.
|
|
122
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
123
|
+
* @returns 0 to 6.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* import { dayOfWeek } from "@johnmorrisdotca/wakusei-planets/time";
|
|
128
|
+
*
|
|
129
|
+
* console.log(dayOfWeek(Date.UTC(1954, 5, 30)));
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export function dayOfWeek(when) {
|
|
133
|
+
return floorMod(Math.floor(moment(when) / DAY_MS) + 4, 7);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The day of the year of a moment in UTC: 1 on 1 January.
|
|
137
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
138
|
+
* @param calendar - `auto` (default), `gregorian` or `julian`.
|
|
139
|
+
* @returns 1 to 366.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* import { dayOfYear } from "@johnmorrisdotca/wakusei-planets/time";
|
|
144
|
+
*
|
|
145
|
+
* console.log(dayOfYear(Date.UTC(1978, 10, 14)), dayOfYear(Date.UTC(1988, 3, 22)));
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export function dayOfYear(when, calendar = "auto") {
|
|
149
|
+
const ms = moment(when);
|
|
150
|
+
const { year } = toCalendar(ms, calendar);
|
|
151
|
+
const dayNumber = Math.floor(ms / DAY_MS) + UNIX_DAY_NUMBER;
|
|
152
|
+
const gregorian = calendar === "gregorian" || (calendar === "auto" && year > 1582);
|
|
153
|
+
return dayNumber - dayNumberOf(year, 1, 1, gregorian) + 1;
|
|
154
|
+
}
|
package/dist/clock.d.ts
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { type When } from "./when.ts";
|
|
2
|
+
export declare const DAY_MS = 86400000;
|
|
3
|
+
/** The Julian date of the Unix epoch, 1970-01-01T00:00:00Z. */
|
|
4
|
+
export declare const UNIX_EPOCH_JD = 2440587.5;
|
|
5
|
+
export declare const TT_MINUS_TAI_SECONDS = 32.184;
|
|
6
|
+
/** The length of a Gregorian year in milliseconds, for turning a time into a decimal year. */
|
|
7
|
+
export declare const YEAR_MS = 31556952000;
|
|
8
|
+
/** TAI minus UTC, in seconds, from the date it took effect (IERS Bulletin C). After the last one, none has been added. */
|
|
9
|
+
export declare const LEAP_SECONDS: readonly (readonly [number, number])[];
|
|
10
|
+
/**
|
|
11
|
+
* A time as a Julian date: the days since noon on 1 January 4713 BC (Julian calendar), as a number. A `Date` or milliseconds since 1970 in, the same scale out (UTC stays UTC).
|
|
12
|
+
* A number near today holds about a tenth of a millisecond; `toJulianDay` and `toMillisecondsInJulianDay` give the same instant with nothing lost.
|
|
13
|
+
* @param when - A `Date` or milliseconds since 1970.
|
|
14
|
+
* @returns The Julian date.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { toJulianDate } from "@johnmorrisdotca/wakusei-planets/time";
|
|
19
|
+
*
|
|
20
|
+
* console.log(toJulianDate(Date.UTC(2013, 10, 21, 10, 47, 2)).toFixed(6));
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function toJulianDate(when: When): number;
|
|
24
|
+
/**
|
|
25
|
+
* The time, in milliseconds since 1970, of a Julian date.
|
|
26
|
+
* @param jd - The Julian date.
|
|
27
|
+
* @returns Milliseconds since 1970.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { fromJulianDate } from "@johnmorrisdotca/wakusei-planets/time";
|
|
32
|
+
*
|
|
33
|
+
* console.log(new Date(fromJulianDate(2451545)).toISOString());
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function fromJulianDate(jd: number): number;
|
|
37
|
+
/**
|
|
38
|
+
* The modified Julian date: the Julian date less 2,400,000.5, so a day starts at midnight and the numbers are shorter.
|
|
39
|
+
* @param when - A `Date` or milliseconds since 1970.
|
|
40
|
+
* @returns The modified Julian date.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* import { modifiedJulianDate } from "@johnmorrisdotca/wakusei-planets/time";
|
|
45
|
+
*
|
|
46
|
+
* console.log(modifiedJulianDate(Date.UTC(2000, 0, 1)));
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function modifiedJulianDate(when: When): number;
|
|
50
|
+
/**
|
|
51
|
+
* The whole Julian day of a time. A Julian day starts at noon, so 11:59 and 12:00 are in different days.
|
|
52
|
+
* @param when - A `Date` or milliseconds since 1970.
|
|
53
|
+
* @returns The integer Julian day number.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { toJulianDay } from "@johnmorrisdotca/wakusei-planets/time";
|
|
58
|
+
*
|
|
59
|
+
* console.log(toJulianDay(Date.UTC(2000, 0, 1, 12)));
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function toJulianDay(when: When): number;
|
|
63
|
+
/**
|
|
64
|
+
* The milliseconds since noon, the start of the Julian day, that a time is into it.
|
|
65
|
+
* @param when - A `Date` or milliseconds since 1970.
|
|
66
|
+
* @returns Milliseconds from 0 up to one day.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* import { toMillisecondsInJulianDay } from "@johnmorrisdotca/wakusei-planets/time";
|
|
71
|
+
*
|
|
72
|
+
* console.log(toMillisecondsInJulianDay(Date.UTC(2000, 0, 1, 18)));
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function toMillisecondsInJulianDay(when: When): number;
|
|
76
|
+
/**
|
|
77
|
+
* A time from a Julian day and the milliseconds into it, with no digit lost: `fromJulianDayAndMilliseconds(toJulianDay(t), toMillisecondsInJulianDay(t))` is `t`.
|
|
78
|
+
* @param day - The integer Julian day number.
|
|
79
|
+
* @param msInDay - Milliseconds since the day began at noon.
|
|
80
|
+
* @returns Milliseconds since 1970.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { fromJulianDayAndMilliseconds, toJulianDay, toMillisecondsInJulianDay } from "@johnmorrisdotca/wakusei-planets/time";
|
|
85
|
+
*
|
|
86
|
+
* const t = Date.UTC(2026, 10, 7, 9, 30, 15, 123);
|
|
87
|
+
* console.log(fromJulianDayAndMilliseconds(toJulianDay(t), toMillisecondsInJulianDay(t)) === t);
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function fromJulianDayAndMilliseconds(day: number, msInDay: number): number;
|
|
91
|
+
export declare function deltaTPolynomial(year: number): number;
|
|
92
|
+
/**
|
|
93
|
+
* Terrestrial time minus the clock's time, in seconds, at a moment given in UTC: 69.184 from the last leap second in 2017 on (until another is added), exact from 1972, and delta T before.
|
|
94
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
95
|
+
* @returns Seconds to add to UTC to get TT.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* import { ttMinusUtc } from "@johnmorrisdotca/wakusei-planets/time";
|
|
100
|
+
*
|
|
101
|
+
* console.log(ttMinusUtc(Date.UTC(2026, 10, 7)));
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export declare function ttMinusUtc(when: When): number;
|
|
105
|
+
/**
|
|
106
|
+
* A moment in UTC as the same moment in terrestrial time, on the same scale of milliseconds since 1970.
|
|
107
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
108
|
+
* @returns The same moment in TT, in milliseconds.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* import { toTerrestrialTime } from "@johnmorrisdotca/wakusei-planets/time";
|
|
113
|
+
*
|
|
114
|
+
* const utc = Date.UTC(2000, 0, 1, 12);
|
|
115
|
+
* console.log((toTerrestrialTime(utc) - utc) / 1000);
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare function toTerrestrialTime(when: When): number;
|
|
119
|
+
/**
|
|
120
|
+
* The Julian date of J2000.0, 2000-01-01 12:00 TT: the epoch of the planets' theories.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* import { J2000_JD, toJulianDate } from "@johnmorrisdotca/wakusei-planets/time";
|
|
125
|
+
*
|
|
126
|
+
* console.log(J2000_JD === toJulianDate(Date.UTC(2000, 0, 1, 12)));
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
export declare const J2000_JD = 2451545;
|
|
130
|
+
/**
|
|
131
|
+
* J2000.0, 2000-01-01 12:00, as milliseconds since 1970 counted on a clock that reads TT: a terrestrial time is this far from it.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* import { J2000_MS } from "@johnmorrisdotca/wakusei-planets/time";
|
|
136
|
+
*
|
|
137
|
+
* console.log(new Date(J2000_MS).toISOString());
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export declare const J2000_MS = 946728000000;
|
|
141
|
+
/**
|
|
142
|
+
* The Julian date of the Besselian epoch B1950.0, 1950 January 0.923 (Meeus).
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* import { B1950_JD } from "@johnmorrisdotca/wakusei-planets/time";
|
|
147
|
+
*
|
|
148
|
+
* console.log(B1950_JD);
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
export declare const B1950_JD = 2433282.4235;
|
|
152
|
+
/**
|
|
153
|
+
* The Julian date of the Unix epoch, 1970-01-01T00:00:00Z (UTC).
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* import { UNIX_EPOCH_JULIAN_DATE, toJulianDate } from "@johnmorrisdotca/wakusei-planets/time";
|
|
158
|
+
*
|
|
159
|
+
* console.log(UNIX_EPOCH_JULIAN_DATE === toJulianDate(0));
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
export declare const UNIX_EPOCH_JULIAN_DATE = 2440587.5;
|
|
163
|
+
/**
|
|
164
|
+
* A time as a string of its Julian date with six decimals, as the `julian` package gives it (a tenth of a second).
|
|
165
|
+
* @param when - A `Date` or milliseconds since 1970.
|
|
166
|
+
* @returns The Julian date as a string.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* import { julian } from "@johnmorrisdotca/wakusei-planets/time";
|
|
171
|
+
*
|
|
172
|
+
* console.log(julian(new Date("2013-11-21T10:47:02Z")));
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
export declare function julian(when: When): string;
|
|
176
|
+
/**
|
|
177
|
+
* The `Date` of a Julian date (a number, or the string `julian` gives), rounded to the millisecond.
|
|
178
|
+
* @param jd - The Julian date.
|
|
179
|
+
* @returns A `Date`.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```ts
|
|
183
|
+
* import { toDate } from "@johnmorrisdotca/wakusei-planets/time";
|
|
184
|
+
*
|
|
185
|
+
* console.log(toDate("2456617.949335").toISOString());
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
export declare function toDate(jd: number | string): Date;
|
|
189
|
+
/**
|
|
190
|
+
* Julian centuries (36,525 days) from J2000.0: the time argument of most theories. In terrestrial time unless `scale` says UTC.
|
|
191
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
192
|
+
* @param scale - `"tt"` (the default, what the theories want) or `"utc"` to count the clock's days.
|
|
193
|
+
* @returns Julian centuries, negative before 2000.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts
|
|
197
|
+
* import { julianCenturies } from "@johnmorrisdotca/wakusei-planets/time";
|
|
198
|
+
*
|
|
199
|
+
* console.log(julianCenturies(Date.UTC(2100, 0, 1, 12)).toFixed(6));
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
export declare function julianCenturies(when: When, scale?: "tt" | "utc"): number;
|
|
203
|
+
/**
|
|
204
|
+
* Julian millennia (365,250 days) from J2000.0, in terrestrial time unless `scale` says UTC: the time argument of the VSOP87 series.
|
|
205
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
206
|
+
* @param scale - `"tt"` (the default) or `"utc"`.
|
|
207
|
+
* @returns Julian millennia, negative before 2000.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```ts
|
|
211
|
+
* import { julianMillennia } from "@johnmorrisdotca/wakusei-planets/time";
|
|
212
|
+
*
|
|
213
|
+
* console.log(julianMillennia(Date.UTC(3000, 0, 1, 12)).toFixed(6));
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
export declare function julianMillennia(when: When, scale?: "tt" | "utc"): number;
|
|
217
|
+
/**
|
|
218
|
+
* TAI minus UTC in seconds: the leap seconds from 1972 (10 then, 37 since 2017), and before 1972 delta T less 32.184, which is how far the atomic scale would have been from the Earth's turn.
|
|
219
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
220
|
+
* @returns Seconds to add to UTC to get TAI.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```ts
|
|
224
|
+
* import { taiMinusUtc } from "@johnmorrisdotca/wakusei-planets/time";
|
|
225
|
+
*
|
|
226
|
+
* console.log(taiMinusUtc(Date.UTC(2026, 10, 7)));
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
export declare function taiMinusUtc(when: When): number;
|
|
230
|
+
/**
|
|
231
|
+
* Delta T, terrestrial time minus universal time (UT1), in seconds. From 1972 it is the leap seconds plus 32.184 s less `dut1` (UT1 minus UTC, which the IERS publishes and is under 0.9 s: leave it out and it is taken as 0),
|
|
232
|
+
* before 1972 the polynomials of Espenak and Meeus (NASA). After the last leap second it is held at 69.184 s, the assumption JPL Horizons makes.
|
|
233
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
234
|
+
* @param dut1 - UT1 minus UTC in seconds, from the IERS; default 0.
|
|
235
|
+
* @returns Seconds.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```ts
|
|
239
|
+
* import { deltaT } from "@johnmorrisdotca/wakusei-planets/time";
|
|
240
|
+
*
|
|
241
|
+
* console.log(deltaT(Date.UTC(1900, 0, 1)).toFixed(1), deltaT(Date.UTC(2026, 10, 7)));
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
export declare function deltaT(when: When, dut1?: number): number;
|