OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
zulu2unix.c
Go to the documentation of this file.
1 #include <timeutils.h>
2 
3 double zulu2unix(char *zulu) {
4  int yy = 0, dd = 0;
5  int hh = 0, mn = 0, sc = 0, cc = 0, mc = 0;
6  int32_t year, day;
7  double sec;
8  int status = 0;
9  int32_t len = 0;
10  len = strlen(zulu);
11 
12  switch (len) {
13  case 7:
14  status = sscanf(zulu, "%4d%3d", &yy, &dd);
15  break;
16  case 9:
17  status = sscanf(zulu, "%4d%3d%2d", &yy, &dd, &hh);
18  break;
19  case 11:
20  status = sscanf(zulu, "%4d%3d%2d%2d", &yy, &dd, &hh, &mn);
21  break;
22  case 13:
23  status = sscanf(zulu, "%4d%3d%2d%2d%2d", &yy, &dd, &hh, &mn, &sc);
24  break;
25  case 15:
26  status = sscanf(zulu, "%4d%3d%2d%2d%2d%2d", &yy, &dd, &hh, &mn, &sc, &cc);
27  break;
28  case 16:
29  case 19:
30  status = sscanf(zulu, "%4d%3d%2d%2d%2d%3d", &yy, &dd, &hh, &mn, &sc, &mc);
31  break;
32  default:
33  printf("%s : unrecognized zulu time format\n", __FILE__);
34  exit(1);
35  }
36  if (status < 2) {
37  printf("%s : problem interpreting zulu time format\n", __FILE__);
38  exit(1);
39  }
40  year = yy;
41  day = dd;
42  sec = (double) (hh * 3600 + mn * 60 + sc + cc / 100. + mc / 1000.);
43 
44  return (yds2unix(year, day, sec));
45 }
46 
int32_t day
int status
Definition: l1_czcs_hdf.c:32
double yds2unix(int16_t year, int16_t day, double secs)
Definition: yds2unix.c:7
double zulu2unix(char *zulu)
Definition: zulu2unix.c:3
integer, parameter double