Julian Dates and the computer
The start of the year 4713 BC was a significant one for astronomy. No-one alive at the time could possibly have known this because it was first determined in 1583 AD by Joseph Scalinger (French, 1540 - 1609). He proposed it as the zero point for a time scale to be known as Julian Days.
Once the Greenwich meridian had been accepted internationally in 1884, the Julian Date (JD) was agreed to be the time on the Greenwich meridian measured in days since noon on January 1st 4713 BC. Scalinger's original suggestion had been to use Ptolemy's meridian at Alexandria.
JD provides a uniform scale of days for recording astronomical events and observations without the complications of years, months and days in various calendars. It makes plotting the light curve of a variable star over a longish period much simpler, for example. Starting at noon is important to remember. For European and African observers it means there is no change of date during a night.
As you can see in the heading of these pages, the value of JD is now quite large. So it is common practice to use a modified JD in which, say, the first 3 digits are chopped off. Data should include a statement when that is being done.
Note that Julian Days are whole numbers of days since noon on day 0 but the Julian Date includes a fraction of a day (according to the Wikipedia entry, which also gives more information about modified forms of JD).
The start of the year 1970 AD was significant in computing for similar reasons. 1970.0 UT is now the zero for time measurement in most computing systems. They measure time in milliseconds from midnight (0h UT) on 1970 January 1st.
1970.0 UT is JD 2440587.5 so there is a constant offset between computer time and Julian Date, making it easy to display as in our heading above. Note that this display is only as accurate as the clock in your computer.
Observers in time zones other than Greenwich have to add an offset to get their local time, which their computer system will do automatically. Julian Date does not involve any time zones.
The number of milliseconds since 1970.0 is
(nowJD - 2440587.5) x msPerDay
At the time of writing (2013 Feb) this is
(2456339.5 - 2440587.5) x 86,400,000
(just over)
= 1,360,972,800,000
= 240
, therefore requiring more than 40 bits to store.
So computers must use at least 6-byte numbers for this value (1 byte = 8 bits) and in practice the next larger convenient size is 8 bytes. In many programming languages that is a data type called long
, or some similar term. That implies that the maximum possible time value (ms since 1970.0) is 263, allowing for a sign bit. That allows for 223 times the amount of time that has elapsed since 1970.0, so we will not run into the limit for millions of years.
JavaScript, the programming language used for displaying JD in our page heading, does not distinguish between different numeric data sizes. All numbers in this language are simply of type Number
. Fortunately the language specification does enable numbers to hold integer parts with the required accuracy.
The code to display JD in our header is in fact very simple:
var SEC_MS = 1000;
var DAY_MS = 24 * 60 * 60 * SEC_MS;
var JD_1970_0 = 2440587.5;
function jdNow ()
{
var ms1970 = new Date ().getTime (); // ms since 1970.0 UT
return ms1970 / DAY_MS + JD_1970_0;
}
function writeJD ()
{
var el = document.getElementById ("jd"); // <div id="jd"> in the HTML
var jdString = jdNow ().toString ().substr (0, 13); // Only show to nearest s.
el.innerHTML = "JD " + jdString;
setTimeout ("writeJD ()", SEC_MS); // Repeat after 1s
}
If you would like to know more about writing simple JavaScript programs there is a gentle introduction here.