Conversion of Gregorian to Julian Date

The following procedure is a modification of a program written by Erik Wischnewski in Turbo Pascal and published in the book Astronomie für die Praxis, Vol. 1. It converts a Gregorian Date such as August 03, 1996, 06:36 pm, to the corresponding Julian Date often used by astronomers. The procedure runs in Maple V R3, R4, R5, as well as in Maple 6 and 7.

The modification allows to input local time as opposed to Universal Time. The first argument represents the difference between local and Universal Time (with the proper sign); daylight saving time must be considered by adding the value 1. The second to fourth argument is the date, passing the local time (fifth to seventh argument) is optional. You can skip either minutes and/or seconds.

Examples for time zones:

The statement invoking juliandate can either be terminated with a comma or semicolon.

The procedure has been tested with two astronomical programs.

> juliandate := proc(difftimezone, day, month, year)
>    # Julian Date; original program written by Erik Wischnewski in 
>    #    Turbo Pascal 
>    # Version 1.00 - August 03, 1996
>    # Version 1.1 - April 21, 1999
>    # usage: juliandate(difftimezone, day, month, year 
>    #                   [, hour [, minutes [, seconds]]])
>    local diffdays, jd, mdays, hrs, minu, secu;
>    if nargs < 4 or nargs > 7 then 
>       ERROR(`Wrong number of arguments, must be between 3 and 6`);
>    fi;
>    mdays := [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
>    hrs := `if`(nargs >= 5, args[5], 0);
>    minu := `if`(nargs >= 6, args[6], 0); 
>    secu := `if`(nargs = 7, args[7], 0);
>    if year < 1600 then jd := 4610895/2
>    elif year > 9999 then jd := 10746967/2 
>    fi;
>    diffdays := (year-1600)*365 + iquo(year-1596, 4) - 
>       iquo(year-1500, 100) + iquo(year-1200, 400) + 
>       mdays[month] + day;
>    if irem(year, 4)=0 and (irem(year, 100) <> 0 or irem(jahr, 400)=0)
>    and month < 3 then
>       diffdays := diffdays-1; 
>       lprint(cat(year ,` is a leap year`));
>    fi;
>    jd := 4610893/2 + diffdays + 
>       (hrs-difftimezone)/24 + minu/1440 + secu/86400;
>    printf(`%.5f \n`, jd);
>    jd
> end:

> juliandate(-4, 3, 8, 1996, 12, 38):
2450299.19306 
The procedure has been saved to a Release 3 MS file which can also be opened and executed in R4 and R5: julian.ms as ASCII file: julian.txt, and as an MWS file for Maple V Release 4 and later: julian.mws.

back

MAPLE UNIVERSE GREGORIAN 1.3 current as of December 25, 2001
Author: Alexander F. Walz, alexander.f.walz@t-online.de
Original file location: http://www.math.utsa.edu/mirrors/maple/mpluniv2.htm