Astronomical time
Meeus, Astronomical Algorithms · checked against USNO, IERS and ERFA
What it is
The sun and moon both stand on these. A calendar date is awkward to do arithmetic with, so astronomy counts days instead: the Julian day is the number of days since noon on 1 January 4713 BC. Clocks keep uniform time, but the Earth’s spin wobbles and slows, and ΔT is the gap between the two, about 69 seconds now and not predictable far ahead. Sidereal time is the Earth’s turn measured against the stars, which says which part of the sky is overhead. With it, any position in the sky becomes two angles for a place on the ground.
- Test these first. When a sunrise is wrong, these cases say whether the fault is underneath.
- ΔT is measured, not computed, so its values expire and the file says when.
- A sidereal day is 23 h 56 min 4 s, about 4 minutes shorter than a solar day.
Operations
| Operation | Gives |
|---|---|
julianDay |
The Julian day of an instantIn: instantUtcOut: julianDay |
calendarDate |
The calendar date of a Julian dayIn: julianDayOut: date, calendar |
deltaT |
ΔT for a dateIn: decimalYearOut: deltaTInSeconds |
siderealTime |
Mean sidereal time at Greenwich and at a longitudeIn: instantUtc, longitudeInDegreesOut: greenwichSiderealTimeInHours, localSiderealTimeInHours |
horizontal |
A sky position as azimuth and altitude from a placeIn: rightAscensionInHours, declinationInDegrees, latitudeInDegrees, longitudeInDegrees, instantUtcOut: azimuthInDegrees, altitudeInDegrees |
Fields
| Field | Meaning |
|---|---|
latitudeInDegrees | −90 to 90, north positive |
longitudeInDegrees | −180 to 180, east positive |
instantUtc | An instant, ISO 8601 with Z, to the second, in decimal digits only. Years −9999 to 9999; before 1 they're astronomical and signed: -4712 is 4713 BC. The Julian calendar before 1582-10-15 and the Gregorian from it; 1582-10-05 to 1582-10-14 never happened and are invalidInput. siderealTime and horizontal read it as UT1. |
julianDay | Days since noon on 1 January 4713 BC in the Julian calendar, with a fraction. Every day is 86,400 s: no leap seconds. calendarDate takes 0 up to, not including, 5,373,484.5, the start of year 10000; outside that, outOfRange. |
date | A calendar date, YYYY-MM-DD, with astronomical years: 1 BC is 0000 and earlier years are negative, like -4712-01-01 |
calendar | gregorian from 1582-10-15, julian before |
decimalYear | The year plus the days before the date over the days in its year, as in the wmm file |
deltaTInSeconds | TT minus UT1: USNO's observed monthly values from 1973-02-01, then its quarterly predictions to the file's expiry. Outside that, outOfRange. |
greenwichSiderealTimeInHours | Greenwich mean sidereal time, 0 up to 24 |
localSiderealTimeInHours | Local mean sidereal time: Greenwich plus longitude over 15, in 0 up to 24 |
rightAscensionInHours | 0 to 24, a sky position's east–west angle. Outside, outOfRange. |
declinationInDegrees | −90 to 90, a sky position's angle north of the celestial equator. Not the magnetic one, which is always magneticDeclinationInDegrees. |
azimuthInDegrees | 0 up to 360, clockwise from north, from the hour angle: local mean sidereal time minus right ascension. Left out where it's undefined: at a pole. |
altitudeInDegrees | −90 to 90, up from the horizon. Geometric: no refraction. |
Edge cases
| Case | What it tests |
|---|---|
usno-julian-day-j2000julianDay | The J2000 epoch: 2451545.0. |
usno-julian-day-gregorian-first-dayjulianDay | The Gregorian calendar's first day: 2299160.5. |
usno-julian-day-julian-last-dayjulianDay | 1582-10-04 in the Julian calendar is followed by 1582-10-15 in the Gregorian. |
usno-julian-day-year-0-leap-dayjulianDay | Year 0 is 1 BC, a Julian leap year. |
usno-julian-day-julian-day-zerojulianDay | Noon on 1 January 4713 BC, written -4712: Julian day 0. |
usno-julian-day-century-not-leapjulianDay | 1900 isn't a Gregorian leap year. |
usno-julian-day-century-leapjulianDay | 2000 is. |
usno-calendar-date-zerocalendarDate | Julian day 0 is -4712-01-01 in the Julian calendar. |
usno-calendar-date-just-before-midnightcalendarDate | A fraction just under .5 is still the day before. |
usno-sidereal-greenwich-j2000siderealTime | Greenwich mean sidereal time at the J2000 epoch. |
usno-sidereal-date-linesiderealTime | At 180°, local is Greenwich plus 12 hours, wrapped. |
erfa-horizontal-below-horizonhorizontal | Below the horizon: a negative altitude, not an error. |
erfa-horizontal-south-pole-observerhorizontal | At a pole azimuth is undefined: only altitude is compared. |
invalid-julian-day-nonexistent-datejulianDay | 1582-10-10 never happened: invalidInput. |
invalid-julian-day-empty-fieldjulianDay | An empty field isn't ISO 8601, even if splitting on colons skips it. |
invalid-julian-day-two-signsjulianDay | Two minus signs aren't a year. |
invalid-julian-day-hexadecimal-secondjulianDay | Decimal digits only: 0x1A isn't 26 seconds. |
invalid-julian-day-signed-monthjulianDay | A sign belongs only before the year. |
invalid-julian-day-exponent-secondjulianDay | Decimal digits only: 1e1 isn't 10 seconds. |
invalid-julian-day-year-10000julianDay | Years run −9999 to 9999: outOfRange. |
invalid-julian-day-year-overflowjulianDay | Too many digits for most integers, but still a year: outOfRange, not invalidInput. |
invalid-horizontal-right-ascension-25horizontal | Right ascension runs 0 to 24 hours: outOfRange, not wrapped. |
invalid-calendar-date-negativecalendarDate | Before Julian day 0: outOfRange. |
invalid-calendar-date-year-10000calendarDate | 10000-01-01 needs a fifth digit in YYYY: outOfRange. |
invalid-calendar-date-hugecalendarDate | Far past any calendar year: outOfRange, not a crash or a wrapped number. |
invalid-delta-t-before-1973deltaT | Before USNO's observed table: outOfRange. |
Their inputs and expected values are in vectors.json; search for the case's id.
For agents
Follow Meeus, Astronomical Algorithms: chapter 7 for the Julian day and back, 12 for mean sidereal time and 13 for the horizontal transform. Use the Julian calendar before 1582-10-15 and the Gregorian from it, with astronomical year numbering, and refuse the ten days that never happened. For deltaTInSeconds, embed USNO’s observed and predicted table from the file’s sources and interpolate between its points. Take the hour angle from local mean sidereal time, treat the UTC given as UT1, and don’t add refraction. Pass every case in vectors.json within its tolerance.
To check by hand against the book, 2nd edition (1998): examples 7.a and 7.b (p. 61), the table on p. 62 and 7.c (p. 64) for the Julian day, 12.a and 12.b (pp. 88 and 89) for mean sidereal time, and 13.b (p. 95) for the horizontal transform. 13.b takes the hour angle from apparent sidereal time, about 0.001° from the mean, and measures azimuth westward from the south, 180° from this file’s. The book’s examples aren’t cases here: the file’s values come from USNO and ERFA.
Test data
vectors.json holds 231 cases, published 2026-11-04. Earth model: Geodetic latitude and longitude; UT1 read from the UTC given. How to read it: Test data format.
| Operation | Cases |
|---|---|
julianDay |
4232 published · 9 edge · 10 invalid |
calendarDate |
2925 published · 10 edge · 4 invalid |
deltaT |
8785 published · 2 invalid |
siderealTime |
2624 published · 4 edge · 2 invalid |
horizontal |
4744 reference · 4 edge · 3 invalid |
Tags say where each value came from: what they mean.
| Field | Tolerance |
|---|---|
julianDay | ± 0.00001 |
deltaTInSeconds | ± 1 |
greenwichSiderealTimeInHours | ± 0.0001 |
localSiderealTimeInHours | ± 0.0001 |
azimuthInDegrees | ± 0.01 |
altitudeInDegrees | ± 0.01 |
Every other field is compared exactly.
Implementations
| Implementation | Status |
|---|---|
| gshaw/algorithms-swiftSwift | Passes |
| gshaw/algorithms-typescriptTypeScript | Passes |
Each implementation's CI grades it against this page's test data on every push, and again when the data changes. The code isn't public yet. See how implementations work.
Source
| Julian days, calendar dates and sidereal time | Astronomical Applications API 4.0.1: Julian Date Converter and Sidereal TimeUS Naval Observatory. Every request and response is in /astronomical-time/sources/usno.jsonl · Public domain |
| ΔT | deltat.data (observed, monthly) and deltat.preds (predicted), IERS Rapid Service/Prediction CenterUS Naval Observatory. Copied verbatim to /astronomical-time/sources/ · Public domain |
| Azimuth and altitude | ERFA 2.0.1, the open-source SOFA: eraGmst82 and eraHd2ae, via pyerfaThe ERFA project, from the IAU's SOFA. Every call is in /astronomical-time/sources/erfa.txt · BSD-3-Clause |
| Method | Astronomical Algorithms, 2nd edition, 1998, chapters 7, 10, 12 and 13Jean Meeus. The method to follow; no value in the file comes from it |