Note: This is a mirror copy of the original web page, uploaded with permission of Peter Hayes
Last update 30 November 2015
Copyright © Peter Hayes 1999-2015.
for your personal use, the Source
Notes describe how to save a copy and how a place is defined.
- If you want to publish a copy, translation or pages using any of my code
on your internet web site you may do so, for non-commercial purposes, as long
as you include this copyright notice and let me know so I can advise you of
any corrections, my e-mail address is Peter
- For commercial uses please contact me for permission, which will be given
for any reasonable uses without charge other than a donation to a mutually
Astronomical Algorithms, first edition, by Jean Meeus, published
by Willmann-Bell and the web pages of
The code has been tested with the
following browsers -
- Internet Explorer version 6 under Windows 2000 and version 7 under XP. I
no longer have access to Microsoft Windows but as long as they support
standards my code should work.
- Mozilla based browsers including FireFox under Mac OS X and
Windows XP. But not iOS on iPad2 and iPhone5s where the result windows are
- Safari under Mac OS X and iOS on an iPad2 and iPhone5s.
- Opera Coast gives the right results on iOS on iPad and iPhone5s but does
to the main page. Opera works on OS X but the calculated windows, Sun &
Moon etc. need to be resized.
- Google Chrome I am not testing any more because I object to them spying on
- My home page also has problems with Safari and iOS, Opera Coast seems more
The following references were of use in the coding.
Several people have kindly pointed out errors, suggested improvements and
supplied code. The main contributors were Stephane Macrez and Nick Reid.
Latest changes are also
documented on the main page, this is the full history.
- 18 December 2011: Minor change to sun.js to fit iPad screen.
- 11 April 2011: Correct position of Capella in stars.js
- 06 January 2011: Correction to datetime.js to fix a typo.
- 20 December 2010: Minor changes to stars.js so constellation is listed
- 22 April 2010 correction in observer.js for DST changing on last day of
- 31 December 2009 a small fix to index.html if a user changes latitude or
longitude and update the copyright notices in case I need to chase astrologers
for unauthorized usage.
- 11 March 2009 corrected observer.js for daylight saving time changes not
on the last Sunday of the month
- 13 August 2008 added and changed some sites in observer.js based on
stellarium sites list
- 21 April 2008 moved one line in index.html to correct DST
- Version 7.1 change to display the local time for the selected
If you have a local copy you need to reload index.html,
observer.js, datetime.js & util.js for the version 7 changes.
- Removed the get date/time/zone button, use reset instead.
- Added code to reset1 to convert to observers local time
- Version 7.0 support for user defined locations
- Thanks to the webmaster at Muskegon Astronomical Society for
suggesting this change and testing it.
- Revised updateplace to reset to location on URL
- Changed table1 to support user changing place name
- Added updatename function
- Changes to reset1, rewrite1 and updatell to support changes
- In observer.js re-wrote the observatory function and initial value of
- In util.js added llstring to convert latitude and longitude
- Change observer.js for new USA daylight saving rules (01/2007)
- Version 6.7 Changes to clockhandler and table for get date/time/timezone
- Merge get date/time with get time zone buttons
- Attempt to derive daylight saving info from browser's host
Code based on method by Dr. J R Stockton
- Version 6.6 Changes to index.html updateplace so the time is kept
consistent with using Name= on the URL.
- Version 6.5 corrections to index.html for time zones E of Greenwich.
- Always display value of zone as positive, E/W flag shows sign.
- Correct time differences for negative values.
- Version 6.4 mainly changes in index.html.
- In reset1 added support for location name as parameter.
- Removed onload from <head> as reset1 called later.
- Added some missing convertra calls (following rewrite1).
- Removed duplicate entry for Cheltenham in observer.js.
- Corrected some HTML in index.html to validate as 4.01 transitional.
- Version 6.3 corrections to time string routines in util.js
- Version 6.2 corrections to index.html
- In function reset1 correct month to observer.month twice.
- Version 6.1 corrections to index.html and util.js
- In function updatelocal check for a change to the timezone W/E option.
- In function reset1 set the daylight saving flag correctly for all cases.
- In function hmsstring correct a typo in the rounding code.
- Version 6.0 - major changes to display time zone and daylight saving time
The underlying code still uses a DST adjusted time zone.
Changes in index.html
- Change table1 replacing UTC-Civil Time with Time Zone and a DST button,
and move UTC-Civil Time to a dropdown menu.
- Changes to functions clockhandler, updatelocal, updateplace and reset1,
- Changes to reset1 so the default time is done better.
- Lots of changes to rewrite1 to support the changes.
- Version 5.5 - changes to index.html, util.js and observer.js
- 'local time' is now UTC corrected for longitude WITHOUT any
daylight saving. This is because of problems with 'unknown' locations.
- Made a daylight saving correction to reset1.
- Added Muskegon
- Version 5.4
- Corrected minor bug in full month tables if the date is after a daylight
- Updated the copyright notices.
- Version 5.3
- Added check for moon up or down all day when neither rise or set found.
- Fixed a silly bug in moon.js that missed a did not set during the day.
- Version 5.2
- Change in index.html so the default is Greenwich CIVIL time with any
daylight saving correction not UTC. This is purely a personal choice and
people who make copies defaulting to other locations may wish to remove it.
It is clearly marked in the source.
- Version 5.1
- Corrected the location of Madrid and Malaga (West not East) and time
zone for Anchorage in observer.js
- Version 5.0 (not really as major a change as version 3 to 4 was)
- Corrections fromOle Nielsen in
moon.js and planets.js for small terms to the obliquity of the ecliptic.
- Version 4.9 -
- Changes to index.html to default to the current date and time at
Greenwich and make the time differences more consistent.
- Version 4.8 -
- Add support for a monthly table in planets.js
- Add support for a monthly table in moon.js
- Changes to sun.js
- Add support for a monthly table.
- Correction for repeats if they cross the daylight saving change.
- Add the monthly buttons to index.html
- Version 4.7
- Added default.css, the same style sheet as for my home page.
- Correction fromOle
Nielsen in planet.js to use the right refraction correction and more
places in observer.js.
- Version 4.6 - Corrections from Dean Davis in moon.js
- Correct my transcription of table T45BL
- Correct my error in understanding the corrections for the eccentricity
of the Earth's orbit.
- Revised equations for Moons mean elongation and anomaly from Meeus
- Version 4.5 - In index.html
- Add noon button for the solar observers.
- Add table headers and change some button names.
- Change the introductory documentation for button changes.
- Version 4.4 - In index.html and notes.html
- change RTC button to Local Date/Time
- commented out the reset button (and for a short time the time zone but
- updated the documentation
- Version 4.3 - Changes to most files
- Alter sun.js to create a sunrise routine
- Ensure for loop variables are declared with var, this to prevent
possible subtle bugs (yes I created one in doing the sunrise routine).
- Version 4.2 - Changes to index.html and datetime.js
- Allow input of Julian date (based on code from Nick Reid).
- Correct a possible 1 second error in time input.
- Version 4.1
- Fixed a bug in planets.js due to changed order for repeated planets and
tidied up the source in the same file.
- Version 4.0
- Split the source into different files.
- Fix in index.html for time differences near midnight.
- Added other cities and towns to observer.js.
- Changed order for repeated planets.
- Version 3.7
- Fixed silly error with angular separation output.
- Added equation of time.
- Corrected Amsterdam location.
- Include daylight saving adjustment in local time.
- Made the table more compact by adding selection options for UTC, local
and siderial time and the time differences.
- Version 3.6
- Improved checking for crossing saving time changes.
- Added local time and changed original local to civil time.
- Change the initial setup of date, time and timezone.
- Added the zone button and changed RTC.
- Version 3.5
- Angular separations based on code from Stephane Macrez.
- Alt/Az to RA/Dec code from Nick Reid.
- Midnight button and more freedom inputting times not just
hh:mm:ss but hh:mm or hh.
- Check for daylight saving time changes after date input.
- Allow for leap years in daylight saving and repeated tables. The
astronomical calculations were always right.
- Add latitude and longitude after location name to top of pages.
- Express time zone as hours:minutes as most people know them that way.
- Version 3.4
- output bright stars altitude & azimuth in degrees & minutes.
- fixed bug for 'unknown' location date / time
- fixed a bug in repeat code & allow user to specify date / time
- Version 3.3
- Additions based on code from Stephane Macrez.
- bright stars
- RA/Dec to Alt/Az converter.
- French locations, I only used a few places though.
- Changed from monthly tables to repeat at user specified time, interval
and repetition count.
- Version 3.2 Added monthly Sun and Moon tables.
- Version 3.1 Daylight saving bug fixes and cosmetic changes to source.
- Version 3.0 First attempts to handle daylight saving time.
- Version 2.9
- Round to 24 hour clock for sunrise/set even if next day
- Fix HTML errors shown by Netscape 6
- Added the Default button and changed RTC to use Time Zone.
- Added the moon phase angle as well as % illuminated.
- Version 2.8 Move the notes sections to a new page
- Version 2.7 Changes removed for version 3.3
- Version 2.6 Fix a silly bug in the moon rise /set calculations
- Version 2.5 Try to speed up moon rise / set calculations
- Version 2.4 Added the illuminated fraction of the moon.
- Version 2.3 corrected a Sun rise/set bug at the equinox.
- Version 2.2
- Corrected moon azimuth/elevation bug
- Used the full Meeus table 45 (see notes for credits)
- Version 2.0 First release to the world of the internet
If you want to keep your own
copy you need to save the files listed below. If you click on the link with the
right button you usually find a "save as" or "save target" option on the menu.
Please read the copyright
notice if you want to use the source on a public web page. Many of the
functions have a parameter obs which is an observatory object as defined below.
If you write your own code remember that you will need to make a copy (my code
shows how) because the object is passed as a reference object.
Defines the front page and the table that drives everything else.
The style sheet I use.
Defines the observers places and functions that define them.
atlas array defines the list of places. The code uses the
first entry as the default location. Add any others you need. The
place function defines how to describe other towns.
- latitude is degrees:minutes:seconds, ns is 0 for north and 1 for south
- longitude is degrees:minutes:seconds, we is 0 for west and 1 for east
- zone is the correction in minutes from local time to UT (Greenwich time)
without daylight saving, west of Greenwich is positive. This is shown in the
table as hours:minutes.
- The daylight saving start and end (dss and dse) are strings
month:week:day where month is 1:12, day is 0-6 (0=Sunday) and week is 1-5.
week 1 is the first week containing 'day' and week 5 means the last
occurence of day in the month (same as the Unix TZ rules). Set the string to
a null string if you don't know the rules. WARNING the code to try to
work out daylight saving is simple minded, it will probably get it wrong
about the hour of the change.
- latitude is in degrees, north is positive
- longitude is in degrees, west is positive
- values contained within observatory object
month values in range 1-12
tz timezone in minutes with any daylight saving (summer
time) correction. See
Calendar and sidereal time functions.
- sun.js The
functions that define the suns position and heliocentric co-ordinates and
creates the Sun page.
The functions that define the moons position and creates the moon page.
The planet functions.
The functions for the bright stars table.
The functions for the angular separation table.
Math functions in degrees.
Utility routines for printing dates times etc.
Sites I used to
test my own code are
US Naval Observatory
heavens-above a site for all sorts of
astronomical tables and diagrams.
For those who want skymaps on your own computer I have used and recommend Stellarium free for Mac OS X, Linux and
want sun and moon data with a map to set your location try The Photographers Ephemeris
This web page was last updated 06/15/18