OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
unix2ymds.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/70 to yr, mon, day, secs of day */
6 
7 /* --------------------------------------------------------------------- */
8 void unix2ymds(double usec, int16_t *year, int16_t *mon, int16_t *day, double *secs) {
9 
10  if (usec == BAD_FLT) {
11  *mon = BAD_INT;
12  *day = BAD_INT;
13  *secs = BAD_FLT;
14  } else {
15  struct tm *trec;
16  time_t utime = (time_t) usec;
17 
18  trec = gmtime(&utime);
19 
20  *year = trec->tm_year + 1900;
21  *day = trec->tm_mday;
22  *mon = trec->tm_mon + 1;
23  *secs = trec->tm_hour * 3600.
24  + trec->tm_min * 60.
25  + trec->tm_sec
26  + fmod(usec, 1.);
27  }
28 }
29 
int32_t day
float tm[MODELMAX]
void unix2ymds(double usec, int16_t *year, int16_t *mon, int16_t *day, double *secs)
Definition: unix2ymds.c:8
#define BAD_FLT
Definition: jplaeriallib.h:19
#define BAD_INT
Definition: genutils.h:23