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.

An observer at the centre of the horizon, with azimuth measured clockwise from north along the horizon and altitude measured up from it
  • 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

OperationGives
julianDay The Julian day of an instantIn: instantUtc
Out: julianDay
calendarDate The calendar date of a Julian dayIn: julianDay
Out: date, calendar
deltaT ΔT for a dateIn: decimalYear
Out: deltaTInSeconds
siderealTime Mean sidereal time at Greenwich and at a longitudeIn: instantUtc, longitudeInDegrees
Out: greenwichSiderealTimeInHours, localSiderealTimeInHours
horizontal A sky position as azimuth and altitude from a placeIn: rightAscensionInHours, declinationInDegrees, latitudeInDegrees, longitudeInDegrees, instantUtc
Out: azimuthInDegrees, altitudeInDegrees

Fields

FieldMeaning
latitudeInDegrees−90 to 90, north positive
longitudeInDegrees−180 to 180, east positive
instantUtcAn 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.
julianDayDays 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.
dateA calendar date, YYYY-MM-DD, with astronomical years: 1 BC is 0000 and earlier years are negative, like -4712-01-01
calendargregorian from 1582-10-15, julian before
decimalYearThe year plus the days before the date over the days in its year, as in the wmm file
deltaTInSecondsTT minus UT1: USNO's observed monthly values from 1973-02-01, then its quarterly predictions to the file's expiry. Outside that, outOfRange.
greenwichSiderealTimeInHoursGreenwich mean sidereal time, 0 up to 24
localSiderealTimeInHoursLocal mean sidereal time: Greenwich plus longitude over 15, in 0 up to 24
rightAscensionInHours0 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.
azimuthInDegrees0 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

CaseWhat it tests
usno-julian-day-j2000julianDayThe J2000 epoch: 2451545.0.
usno-julian-day-gregorian-first-dayjulianDayThe Gregorian calendar's first day: 2299160.5.
usno-julian-day-julian-last-dayjulianDay1582-10-04 in the Julian calendar is followed by 1582-10-15 in the Gregorian.
usno-julian-day-year-0-leap-dayjulianDayYear 0 is 1 BC, a Julian leap year.
usno-julian-day-julian-day-zerojulianDayNoon on 1 January 4713 BC, written -4712: Julian day 0.
usno-julian-day-century-not-leapjulianDay1900 isn't a Gregorian leap year.
usno-julian-day-century-leapjulianDay2000 is.
usno-calendar-date-zerocalendarDateJulian day 0 is -4712-01-01 in the Julian calendar.
usno-calendar-date-just-before-midnightcalendarDateA fraction just under .5 is still the day before.
usno-sidereal-greenwich-j2000siderealTimeGreenwich mean sidereal time at the J2000 epoch.
usno-sidereal-date-linesiderealTimeAt 180°, local is Greenwich plus 12 hours, wrapped.
erfa-horizontal-below-horizonhorizontalBelow the horizon: a negative altitude, not an error.
erfa-horizontal-south-pole-observerhorizontalAt a pole azimuth is undefined: only altitude is compared.
invalid-julian-day-nonexistent-datejulianDay1582-10-10 never happened: invalidInput.
invalid-julian-day-empty-fieldjulianDayAn empty field isn't ISO 8601, even if splitting on colons skips it.
invalid-julian-day-two-signsjulianDayTwo minus signs aren't a year.
invalid-julian-day-hexadecimal-secondjulianDayDecimal digits only: 0x1A isn't 26 seconds.
invalid-julian-day-signed-monthjulianDayA sign belongs only before the year.
invalid-julian-day-exponent-secondjulianDayDecimal digits only: 1e1 isn't 10 seconds.
invalid-julian-day-year-10000julianDayYears run −9999 to 9999: outOfRange.
invalid-julian-day-year-overflowjulianDayToo many digits for most integers, but still a year: outOfRange, not invalidInput.
invalid-horizontal-right-ascension-25horizontalRight ascension runs 0 to 24 hours: outOfRange, not wrapped.
invalid-calendar-date-negativecalendarDateBefore Julian day 0: outOfRange.
invalid-calendar-date-year-10000calendarDate10000-01-01 needs a fifth digit in YYYY: outOfRange.
invalid-calendar-date-hugecalendarDateFar past any calendar year: outOfRange, not a crash or a wrapped number.
invalid-delta-t-before-1973deltaTBefore 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.

OperationCases
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.

FieldTolerance
julianDay± 0.00001
deltaTInSeconds± 1
greenwichSiderealTimeInHours± 0.0001
localSiderealTimeInHours± 0.0001
azimuthInDegrees± 0.01
altitudeInDegrees± 0.01

Every other field is compared exactly.

Implementations

ImplementationStatus
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 timeAstronomical 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
ΔTdeltat.data (observed, monthly) and deltat.preds (predicted), IERS Rapid Service/Prediction CenterUS Naval Observatory. Copied verbatim to /astronomical-time/sources/ · Public domain
Azimuth and altitudeERFA 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
MethodAstronomical Algorithms, 2nd edition, 1998, chapters 7, 10, 12 and 13Jean Meeus. The method to follow; no value in the file comes from it