OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
unix2yds.c
Go to the documentation of this file.
1 #include <timeutils.h>
2 #include <genutils.h>
3 
4 /* --------------------------------------------------------------- */
5 /* unix2yds() - converts secs since 1/1/70 to yr, day, secs of day */
6 /* --------------------------------------------------------------- */
7 void unix2yds(double usec, int16_t *year, int16_t *day, double *secs) {
8  if (usec == BAD_FLT) {
9  *year = BAD_INT;
10  *day = BAD_INT;
11  *secs = BAD_FLT;
12  } else {
13  struct tm *trec;
14  time_t utime = (time_t) usec;
15 
16  trec = gmtime(&utime);
17 
18  *year = trec->tm_year + 1900;
19  *day = trec->tm_yday + 1;
20  *secs = trec->tm_hour * 3600.
21  + trec->tm_min * 60.
22  + trec->tm_sec
23  + fmod(usec, 1.);
24  }
25 }
26 
void unix2yds(double usec, int16_t *year, int16_t *day, double *secs)
Definition: unix2yds.c:7
int32_t day
float tm[MODELMAX]
#define BAD_FLT
Definition: jplaeriallib.h:19
#define BAD_INT
Definition: genutils.h:23