OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
ccsds_to_yds.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdint.h>
3 #include <timeutils.h>
4 
5 int ccsds_to_yds(uint8_t *cctime,
6  int32_t *iyear, int32_t *iday, double *sec) {
7 
8  // Convert CCSDS time code to year, day-of-year and seconds-of-day
9  *iday = cctime[0]*256 + cctime[1];
10  int32_t jday = *iday + 2436205; // Jan. 1, 1958 is Julian day 2436205
11  jdate(jday, iyear, iday);
12 
13  // Get milliseconds of day count
14  int32_t msec = ((cctime[2]*256 + cctime[3])*256 + cctime[4])*256 + cctime[5];
15 
16  // Get microseconds
17  int32_t musec = cctime[6]*256 + cctime[7];
18 
19  *sec = msec / (double) 1000.0 + musec / (double) 1.e6;
20 
21  return 0;
22 }
int32 * msec
Definition: l1_czcs_hdf.c:31
int jdate(int32_t julian, int32_t *year, int32_t *doy)
Definition: jdate.c:5
int32_t jday(int16_t i, int16_t j, int16_t k)
Definition: jday.c:4
int ccsds_to_yds(uint8_t *cctime, int32_t *iyear, int32_t *iday, double *sec)
Definition: ccsds_to_yds.c:5
integer, parameter double