<HTML><HEAD>
<!--
-----------
Julian Days
-----------
-->
<SCRIPT LANGUAGE="JavaScript"><!-- hide from old browsers
/*
THE JAVASCRIPT COOKBOOK by Erica Sadun, webrx@mindspring.com
Copyright (C)1998 by Charles River Media. All Rights Reserved.
This applet can only be re-used or modifed by license holders of the
JavaScript Cookbook CD-ROM. Credit must be given in the source
code and this copyright notice must be maintained. If you do
not hold a license to the JavaScript Cookbook, you may NOT
duplicate or modify this code for your own use.
Use at your own risk. No warranty is given or implied of the suitability
of this applet for any specific application. Neither Erica Sadun nor
Charles River Media will be held responsible for any unwanted effects
due to the use of this applet or any derivative.
*/
function julianDay(m, d, y)
{
var jYear, jDay, jMonth, jul
var greg = 15 + 10*31 + (12 * 31* 1582) // Gregorian Adoption
if (m > 2) // Check for February
{jYear = y; jMonth = m + 1}
else
{jYear = y - 1; jMonth = m + 13}
jul = Math.floor(365.25 * jYear) + // Adapt to Julian
Math.floor(30.6001 * jMonth) +
d + 1720995
if ((d + 31*m + (12 * 31 * y)) > greg) // After Adoption
{
jDay = Math.floor(0.01 * jYear)
jul += 2 - jDay + Math.floor(0.25 * jDay)
}
return jul
}
function doJulian()
{
var m = document.forms[0].month.options.selectedIndex + 1
var d = parseInt(document.forms[0].date.value)
var y = parseInt(document.forms[0].year.value)
document.forms[0].julian.value = ''+julianDay(m, d, y)
}
<!-- done hiding --></SCRIPT></HEAD>
<BODY bgcolor="ffffff" link="0000ff" vlink="770077">
<FONT COLOR="007777"><H1><IMG SRC="../GRAFX/UTENS.JPG" WIDTH=80 HEIGHT=50
ALIGN = LEFT>Julian Days</H1></FONT>
<BLOCKQUOTE><FONT COLOR="770000">
Today's Julian Day is:
<SCRIPT>
var now = new Date()
document.write(julianDay(now.getMonth()+1, now.getDate(),1900+now.getYear()))
</SCRIPT>
<P><FORM>
<PRE
> Month: <SELECT NAME='month' SIZE=1>
<OPTION>January
<OPTION>February
<OPTION>March
<OPTION>April
<OPTION>May
<OPTION>June
<OPTION>July
<OPTION>August
<OPTION>September
<OPTION>October
<OPTION>November
<OPTION>December
</SELECT>
Date: <INPUT NAME='date' TYPE='TEXT' VALUE='1' SIZE=3>
Year: <INPUT NAME='year' VALUE='1998' TYPE='TEXT' SIZE=5
></PRE><p>
<INPUT TYPE='BUTTON' onClick='doJulian()' value='Julian Day'>
<INPUT TYPE='TEXT' NAME='julian'>
</FORM>
</FONT></BLOCKQUOTE>
<FONT COLOR="007777"><H2>Discussion</H2></FONT>
<FONT SIZE=4>
This handy utility converts dates to Julian form. If you're in
the habit of watching the stars, searching for comets or need to
know when the next new moon will be, this utility may be of use
to you.
</FONT>
<h5>Copyright ©1998 by Charles River Media, All Rights Reserved</h5>
</BODY>
</HTML>