1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
############################################################################
#
# File: calendat.icn
#
# Subject: Procedure to get date from Julian Day Number
#
# Author: Ralph E. Griswold
#
# Date: March 25, 2002
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# calendat(j) return a record with the month, day, and year corresponding
# to the Julian Date Number j.
#
############################################################################
#
# 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;
# Cambridge University Press, 1986.
#
############################################################################
record date1(month, day, year)
procedure calendat(julian)
local ja, jalpha, jb, jc, jd, je, gregorian
local month, day, year
gregorian := 2299161
if julian >= gregorian then {
jalpha := integer(((julian - 1867216) - 0.25) / 36524.25)
ja := julian + 1 + jalpha - integer(0.25 * jalpha)
}
else ja := julian
jb := ja + 1524
jc := integer(6680.0 + ((jb - 2439870) - 122.1) / 365.25)
jd := 365 * jc + integer(0.25 * jc)
je := integer((jb - jd) / 30.6001)
day := jb - jd - integer(30.6001 * je)
month := je - 1
if month > 12 then month -:= 12
year := jc - 4715
if month > 2 then year -:= 1
if year <= 0 then year -:= 1
return date1(month, day, year)
end
|