Last change
on this file since 10058 was 731, checked in by tbretz, 24 years ago |
*** empty log message ***
|
-
Property svn:executable
set to
*
|
File size:
1.4 KB
|
Line | |
---|
1 | #include "slalib.h"
|
---|
2 | #include "slamac.h"
|
---|
3 | void slaDjcl ( double djm, int *iy, int *im, int *id, double *fd, int *j)
|
---|
4 | /*
|
---|
5 | ** - - - - - - - -
|
---|
6 | ** s l a D j c l
|
---|
7 | ** - - - - - - - -
|
---|
8 | **
|
---|
9 | ** Modified Julian Date to Gregorian year, month, day,
|
---|
10 | ** and fraction of a day.
|
---|
11 | **
|
---|
12 | ** Given:
|
---|
13 | ** djm double Modified Julian Date (JD-2400000.5)
|
---|
14 | **
|
---|
15 | ** Returned:
|
---|
16 | ** *iy int year
|
---|
17 | ** *im int month
|
---|
18 | ** *id int day
|
---|
19 | ** *fd double fraction of day
|
---|
20 | ** *j int status:
|
---|
21 | ** -1 = unacceptable date (before 4701BC March 1)
|
---|
22 | **
|
---|
23 | ** The algorithm is derived from that of Hatcher 1984 (QJRAS 25, 53-55).
|
---|
24 | **
|
---|
25 | ** Defined in slamac.h: dmod
|
---|
26 | **
|
---|
27 | ** Last revision: 12 March 1998
|
---|
28 | **
|
---|
29 | ** Copyright P.T.Wallace. All rights reserved.
|
---|
30 | */
|
---|
31 | {
|
---|
32 | double f, d;
|
---|
33 | long jd, n4, nd10;
|
---|
34 |
|
---|
35 | /* Check if date is acceptable */
|
---|
36 | if ( ( djm <= -2395520.0 ) || ( djm >= 1e9 ) ) {
|
---|
37 | *j = -1;
|
---|
38 | return;
|
---|
39 | } else {
|
---|
40 | *j = 0;
|
---|
41 |
|
---|
42 | /* Separate day and fraction */
|
---|
43 | f = dmod ( djm, 1.0 );
|
---|
44 | if ( f < 0.0 ) f += 1.0;
|
---|
45 | d = djm - f;
|
---|
46 | d = dnint ( d );
|
---|
47 |
|
---|
48 | /* Express day in Gregorian calendar */
|
---|
49 | jd = (long) dnint ( d ) + 2400001;
|
---|
50 | n4 = 4L*(jd+((6L*((4L*jd-17918L)/146097L))/4L+1L)/2L-37L);
|
---|
51 | nd10 = 10L*(((n4-237L)%1461L)/4L)+5L;
|
---|
52 | *iy = (int) (n4/1461L-4712L);
|
---|
53 | *im = (int) (((nd10/306L+2L)%12L)+1L);
|
---|
54 | *id = (int) ((nd10%306L)/10L+1L);
|
---|
55 | *fd = f;
|
---|
56 | *j = 0;
|
---|
57 | }
|
---|
58 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.