OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
jdate.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdint.h>
3 #include <timeutils.h>
4 
5 int jdate(int32_t julian, int32_t *year, int32_t *doy) {
6 
7  int i;
8  int32_t month, day;
9 
10  int32_t ja, jb, jc, jd, je, jalpha;
11 
12  jalpha = (int32_t) (((julian - 1867216L) - 0.25) / 36524.25);
13  ja = julian + 1 + jalpha - (int32_t) (0.25 * jalpha);
14 
15  jb = ja + 1524;
16  jc = (int32_t) (6680.0 + ((jb - 2439870L) - 122.1) / 365.25);
17  jd = 365 * jc + (int32_t) (0.25 * jc);
18  je = (int32_t) ((jb - jd) / 30.6001);
19 
20  day = jb - jd - (int32_t) (30.6001 * je);
21  month = je - 1;
22  if (month > 12)
23  month = month - 12;
24  *year = jc - 4715;
25 
26  if (month > 2) *year = *year - 1;
27  if (*year <= 0) *year = *year - 1;
28 
29  int dmn[24] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
30  31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
31 
32  *doy = day;
33  for (i = 1; i < month; i++) *doy = *doy + dmn[isleap(*year) * 12 + (i - 1)];
34 
35  return 0;
36 }
int32_t day
#define L(lambda, T)
Definition: PreprocessP.h:185
function jd(i, j, k)
Definition: jd.f:2
int jb
Definition: atrem_corl1.h:227
int jdate(int32_t julian, int32_t *year, int32_t *doy)
Definition: jdate.c:5
Definition: jd.py:1
int isleap(int year)
Definition: isleap.c:3
float ja
Definition: atrem_cor.h:114
integer function julian(DAY, MONTH, YEAR)
Definition: julian.f:2
int i
Definition: decode_rs.h:71