OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
ymds2unix.c
Go to the documentation of this file.
1 #include <time.h>
2 #include <timeutils.h>
3 #include <ctype.h>
4 
5 /* ------------------------------------------------------------------- *
6  * ymds2unix() - converts yr (ie 2002), mon (1-12), and day (1-31) of *
7  * month to secs since 1/1/70 *
8  * ------------------------------------------------------------------- */
9 double ymds2unix(int16_t year, int16_t month, int16_t day, double secs) {
10  double usec;
11  struct tm trec;
12  time_t secSince;
13 
14  /* */
15  /* calculate seconds from 1/1/70 to input year, day */
16  /* and correct to GMT */
17  /* */
18  trec.tm_year = year - 1900;
19  trec.tm_mon = month - 1;
20  trec.tm_mday = day;
21  trec.tm_hour = 0;
22  trec.tm_min = 0;
23  trec.tm_sec = 0;
24  trec.tm_isdst = 0;
25  secSince = mktime(&trec) - gmt_offset();
26 
27  /* */
28  /* Now we total the seconds */
29  /* */
30  usec = secSince + secs;
31 
32  return usec;
33 }
int32_t day
time_t gmt_offset(void)
Definition: gmt_offset.c:8
float tm[MODELMAX]
double ymds2unix(int16_t year, int16_t month, int16_t day, double secs)
Definition: ymds2unix.c:9