OB.DAAC Logo
NASA Logo
Ocean Color Science Software

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