OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
unix2ymdhms.c
Go to the documentation of this file.
1 #include <timeutils.h>
2 #include <genutils.h>
3 
4 /* --------------------------------------------------------------------- *
5  * unix2ymds() - converts secs since 1/1/1970 to *
6  * yr(2013), mon(1-12), day(1-31), hour, min, secs *
7  * --------------------------------------------------------------------- */
8 void unix2ymdhms(double usec, int16_t *year, int16_t *mon, int16_t *day, int16_t *hour, int16_t *min, double *sec) {
9 
10  if (usec == BAD_FLT) {
11  *year = BAD_INT;
12  *mon = BAD_INT;
13  *day = BAD_INT;
14  *hour = BAD_INT;
15  *min = BAD_INT;
16  *sec = BAD_FLT;
17  } else {
18  struct tm *trec;
19  time_t utime = (time_t) usec;
20 
21  trec = gmtime(&utime);
22 
23  *year = trec->tm_year + 1900;
24  *mon = trec->tm_mon + 1;
25  *day = trec->tm_mday;
26  *hour = trec->tm_hour;
27  *min = trec->tm_min;
28  *sec = trec->tm_sec + fmod(usec, 1.);
29  }
30 }
31 
int32_t day
These are used to scale the SD before writing it to the HDF4 file The default is and which means the product is not scaled at all Since the product is usually stored as a float inside of this is a way to write the float out as a integer l2prod min
float tm[MODELMAX]
void unix2ymdhms(double usec, int16_t *year, int16_t *mon, int16_t *day, int16_t *hour, int16_t *min, double *sec)
Definition: unix2ymdhms.c:8
#define BAD_FLT
Definition: jplaeriallib.h:19
#define BAD_INT
Definition: genutils.h:23