home *** CD-ROM | disk | FTP | other *** search
- ############################################################################
- #
- # File: julian.icn
- #
- # Subject: Procedure to produce Julian Day Number
- #
- # Author: Ralph E. Griswold
- #
- # Date: September 6, 1992
- #
- ###########################################################################
- #
- # julian(m, d, y) returns the Julian Day Number for the specified
- # month, day, and year.
- #
- ############################################################################
- #
- # Acknowledgement: This procedure is based on an algorithm given in
- # "Numerical Recipes; The Art of Scientific Computing"; William H. Press,
- # Brian P. Flannery, Saul A. Teukolsky. and William T. Vetterling;
- # Cambrdayge University Press, 1986.
- #
- ############################################################################
-
- procedure julian(month, day, year)
- local jul, gregorian, ja, julian_year, julian_month
-
- gregorian := (15 + 31 * (10 + 12 * 1582))
-
- if year = 0 then fail
- if year < 0 then year +:= 1
- if month > 2 then {
- julian_year := year
- julian_month := month + 1
- } else {
- julian_year := year - 1
- julian_month := month + 13
- }
- jul := (integer(365.25 * julian_year) + integer(30.6001 * julian_month) +
- day + 1720995)
- if day + 31 * (month + 12 * year) >= gregorian then {
- ja := integer(0.01 * julian_year)
- jul +:= 2 - ja + integer(0.25 * ja)
- }
-
- return jul
-
- end
-