source: trunk/FACT++/pal/palCaldj.c@ 18403

Last change on this file since 18403 was 18347, checked in by tbretz, 9 years ago
File size: 2.8 KB
Line 
1/*
2*+
3* Name:
4* palCaldj
5
6* Purpose:
7* Gregorian Calendar to Modified Julian Date
8
9* Language:
10* Starlink ANSI C
11
12* Type of Module:
13* Library routine
14
15* Invocation:
16* void palCaldj ( int iy, int im, int id, double *djm, int *j );
17
18* Arguments:
19* iy = int (Given)
20* Year in the Gregorian calendar
21* im = int (Given)
22* Month in the Gergorian calendar
23* id = int (Given)
24* Day in the Gregorian calendar
25* djm = double * (Returned)
26* Modified Julian Date (JD-2400000.5) for 0 hrs
27* j = status (Returned)
28* 0 = OK. See eraCal2jd for other values.
29
30* Description:
31* Modified Julian Date to Gregorian Calendar with special
32* behaviour for 2-digit years relating to 1950 to 2049.
33
34* Authors:
35* PTW: Pat Wallace (STFC)
36* TIMJ: Tim Jenness (JAC, Hawaii)
37* {enter_new_authors_here}
38
39* History:
40* 2012-02-11 (TIMJ):
41* Initial version with documentation taken from Fortran SLA
42* Adapted with permission from the Fortran SLALIB library.
43* {enter_further_changes_here}
44
45* Notes:
46* - Uses eraCal2jd
47* - Unlike eraCal2jd this routine treats the years 0-100 as
48* referring to the end of the 20th Century and beginning of
49* the 21st Century. If this behaviour is not acceptable
50* use the SOFA/ERFA routine directly or palCldj.
51* Acceptable years are 00-49, interpreted as 2000-2049,
52* 50-99, " " 1950-1999,
53* all others, interpreted literally.
54* - Unlike SLA this routine will work with negative years.
55
56
57* Copyright:
58* Copyright (C) 1995 Rutherford Appleton Laboratory
59* Copyright (C) 2012 Science and Technology Facilities Council.
60* All Rights Reserved.
61
62* Licence:
63* This program is free software: you can redistribute it and/or
64* modify it under the terms of the GNU Lesser General Public
65* License as published by the Free Software Foundation, either
66* version 3 of the License, or (at your option) any later
67* version.
68*
69* This program is distributed in the hope that it will be useful,
70* but WITHOUT ANY WARRANTY; without even the implied warranty of
71* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
72* GNU Lesser General Public License for more details.
73*
74* You should have received a copy of the GNU Lesser General
75* License along with this program. If not, see
76* <http://www.gnu.org/licenses/>.
77
78* Bugs:
79* {note_any_bugs_here}
80*-
81*/
82
83#include "pal.h"
84#include "palmac.h"
85#include "pal1sofa.h"
86
87void palCaldj ( int iy, int im, int id, double *djm, int *j ) {
88 int adj = 0; /* Year adjustment */
89 double djm0;
90
91 if (iy >= 0 && iy <= 49) {
92 adj = 2000;
93 } else if (iy >= 50 && iy <= 99) {
94 adj = 1900;
95 }
96 iy += adj;
97
98 *j = eraCal2jd( iy, im, id, &djm0, djm );
99}
Note: See TracBrowser for help on using the repository browser.