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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
use cratejd2cal;
/// Julian Date to Gregorian Calendar, expressed in a form convenient
/// for formatting messages: rounded to a specified precision.
///
/// This function is part of the International Astronomical Union's
/// SOFA (Standards of Fundamental Astronomy) software collection.
///
/// Status: support function.
///
/// # Given:
/// * `ndp`: number of decimal places of days in fraction
/// * `dj1`, `dj2`: dj1+dj2 = Julian Date (Note 1)
///
/// # Returned:
/// * `(iy, im, id, iymdf_3)`: year, month, day, fraction in Gregorian calendar
///
/// # Returned (function value):
/// * `Result`:
/// * `Ok(status)`:
/// * `0` = OK
/// * `1` = ndp not 0-9 (interpreted as 0)
/// * `Err(status)`:
/// * `-1` = date out of range
///
/// # Notes:
/// 1) The Julian Date is apportioned in any convenient way between
/// the arguments dj1 and dj2. For example, JD=2450123.7 could
/// be expressed in any of these ways, among others:
///
/// dj1 dj2
///
/// 2450123.7 0.0 (JD method)
/// 2451545.0 -1421.3 (J2000 method)
/// 2400000.5 50123.2 (MJD method)
/// 2450123.5 0.2 (date & time method)
///
/// 2) In early eras the conversion is from the "Proleptic Gregorian
/// Calendar"; no account is taken of the date(s) of adoption of
/// the Gregorian Calendar, nor is the AD/BC numbering convention
/// observed.
///
/// 3) See also the function iauJd2cal.
///
/// 4) The number of decimal places ndp should be 4 or less if internal
/// overflows are to be avoided on platforms which use 16-bit
/// integers.
///
/// # Reference:
/// Explanatory Supplement to the Astronomical Almanac,
/// P. Kenneth Seidelmann (ed), University Science Books (1992),
/// Section 12.92 (p604).
/* dnint(A) - round to nearest whole number (double) */