OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
epochbk.c
Go to the documentation of this file.
1 /*****************************************************************
2  *
3  * NSSDC/CDF EPOCHbreakdown.
4  *
5  * Version 2.0, 10-Jul-91, ST Systems (STX)
6  *
7  * Modification history:
8  *
9  * V1.0 ~11-Feb-91, J Love Original version (for CDF V2.0). Used
10  * algorithm from EPOCH_BREAKDOWN.F (author
11  * unknown).
12  * V1.1 9-Jul-91, J Love Added include of 'math.h'.
13  * V2.0 10-Jul-91, J Love Renamed (was EPOCH_BREAKDOWN.C in CDF V2.0
14  * distribution).
15  *
16  *******************************************************************/
17 
18 #include <math.h>
19 
20 void EPOCHbreakdown(epoch, year, month, day, hour, minute, second, msec)
21 double epoch;
22 long *year, *month, *day, *hour, *minute, *second, *msec;
23 {
24  long jd, i, j, k, l, n;
25  double msecAD, secondAD, minuteAD, hourAD, dayAD;
26 
27  msecAD = epoch;
28  secondAD = msecAD / 1000.0;
29  minuteAD = secondAD / 60.0;
30  hourAD = minuteAD / 60.0;
31  dayAD = hourAD / 24.0;
32 
33  jd = 1721060 + dayAD;
34  l = jd + 68569;
35  n = 4 * l / 146097;
36  l = l - (146097 * n + 3) / 4;
37  i = 4000 * (l + 1) / 1461001;
38  l = l - 1461 * i / 4 + 31;
39  j = 80 * l / 2447;
40  k = l - 2447 * j / 80;
41  l = j / 11;
42  j = j + 2 - 12 * l;
43  i = 100 * (n - 49) + i + l;
44 
45  *year = i;
46  *month = j;
47  *day = k;
48 
49  *hour = fmod(hourAD, 24.0);
50  *minute = fmod(minuteAD, 60.0);
51  *second = fmod(secondAD, 60.0);
52  *msec = fmod(msecAD, 1000.0);
53 
54  return;
55 }
int j
Definition: decode_rs.h:73
int32_t day
function jd(i, j, k)
Definition: jd.f:2
int32 * msec
Definition: l1_czcs_hdf.c:31
void EPOCHbreakdown(double epoch, long *year, long *month, long *day, long *hour, long *minute, long *second, long *msec)
Definition: epochbk.c:20
Definition: jd.py:1
int i
Definition: decode_rs.h:71
int k
Definition: decode_rs.h:73