NASA Logo
Ocean Color Science Software

ocssw V2022
timeutils.h
Go to the documentation of this file.
1 #ifndef _TIME_UTILS_H
2 #define _TIME_UTILS_H
3 
4 #include <stdint.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <time.h>
9 #include <math.h>
10 
11 #define SECONDS_IN_DAY 86400
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 int isleap(int year);
18 
19 time_t gmt_offset(void);
20 double yds2unix(int16_t year, int16_t day, double secs);
21 double yds2unix_(int16_t *year, int16_t *day, double *secs);
22 void unix2yds(double usec, int16_t *year, int16_t *day, double *secs);
23 char * unix2ydhmsf(double usec, char zone);
24 double ymds2unix(int16_t year, int16_t month, int16_t day, double secs);
25 void unix2ymds(double usec, int16_t *year, int16_t *mon, int16_t *day, double *secs);
26 void unix2ymdhms(double usec, int16_t *year, int16_t *mon, int16_t *day, int16_t *hour, int16_t *min, double *sec);
27 void yd2md(int16_t year, int16_t doy, int16_t *month, int16_t *dom);
28 char * ydhmsf(double dtime, char zone);
29 double now(void);
30 void ymdhms2ydmsec(int yy, int mm, int dd, int hh, int mn, int sc,
31  int32_t *year, int32_t *day, int32_t *msec);
32 void date2ydmsec(char *date, int32_t *year, int32_t *day, int32_t *msec);
33 char * unix2isodate(double dtime, char zone);
34 double isodate2unix(const char *isodate);
35 void isodate2ydmsec(char *date, int32_t *year, int32_t *day, int32_t *msec);
36 void isodate2ymds(const char *isodate, int16_t *year, int16_t *month, int16_t *day, double *sec);
37 double zulu2unix(char *zulu);
38 void addmsec(int32_t *year, int32_t *day, int32_t *msec, int32_t delta);
39 
40 void get_time(char *pr_time);
41 
42 int leapseconds_since_1993(double tai93time);
43 int leapseconds_since_1993_unix(double unixtime);
44 double unix_to_tai93(double unixtime);
45 double tai93_to_unix(double tai93);
46 double unix_to_tai58(double unixtime);
47 double tai58_to_unix(double tai58);
48 
49 int32_t jday(int16_t year, int16_t month, int16_t day);
50 int jdate(int32_t julianDay, int32_t *year, int32_t *dayOfYear);
51 double yds2tai93(int16_t iyr, int16_t idy, double sec);
52 int ccsds_to_yds(uint8_t *cctime, int32_t *iyear, int32_t *iday, double *sec);
53 
54 double udunits2unix(const char* str);
55 const char* unix2udunits_c(double unixtime, int hasZ);
56 
57 #ifdef __cplusplus
58 } // end extern "C"
59 
60 #include <string>
61 
62 double udunits2unix(const std::string& str);
63 std::string unix2udunits(double unixtime, bool hasZ = true);
64 
65 #endif
66 
67 #endif
char * ydhmsf(double dtime, char zone)
Definition: ydhmsf.c:12
double ymds2unix(int16_t year, int16_t month, int16_t day, double secs)
Definition: ymds2unix.c:9
void get_time(char *pr_time)
Definition: get_time.c:28
int32_t day
double yds2unix(int16_t year, int16_t day, double secs)
Definition: yds2unix.c:7
int isleap(int year)
Definition: isleap.c:3
These are used to scale the SD before writing it to the HDF4 file The default is and which means the product is not scaled at all Since the product is usually stored as a float inside of this is a way to write the float out as a integer l2prod min
char * unix2ydhmsf(double usec, char zone)
Definition: unix2ydhmsf.c:8
void unix2ymds(double usec, int16_t *year, int16_t *mon, int16_t *day, double *secs)
Definition: unix2ymds.c:8
double yds2tai93(int16_t iyr, int16_t idy, double sec)
Definition: yds2tai.c:4
int32 * msec
Definition: l1_czcs_hdf.c:31
void unix2yds(double usec, int16_t *year, int16_t *day, double *secs)
Definition: unix2yds.c:7
int32_t jday(int16_t year, int16_t month, int16_t day)
Converts a calendar date to the corresponding Julian day starting at noon on the calendar date....
Definition: jday.c:14
@ string
double udunits2unix(const char *str)
int leapseconds_since_1993_unix(double unixtime)
Definition: leapsecond.c:71
int jdate(int32_t julianDay, int32_t *year, int32_t *dayOfYear)
Takes in a julian day and mutates year and doy to contain the gregorian year and day of that gregoria...
Definition: jdate.c:13
double unix_to_tai93(double unixtime)
Definition: yds2tai.c:11
void yd2md(int16_t year, int16_t doy, int16_t *month, int16_t *dom)
Definition: yd2md.c:6
double zulu2unix(char *zulu)
Definition: zulu2unix.c:3
double tai93_to_unix(double tai93)
Definition: yds2tai.c:16
double unix_to_tai58(double unixtime)
Definition: yds2tai.c:23
const double delta
void addmsec(int32_t *year, int32_t *day, int32_t *msec, int32_t delta)
Definition: addmsec.c:3
void date2ydmsec(char *date, int32_t *year, int32_t *day, int32_t *msec)
Definition: date2ydmsec.c:4
void isodate2ymds(const char *isodate, int16_t *year, int16_t *month, int16_t *day, double *sec)
Definition: unix2isodate.c:73
string unix2udunits(double unixtime, bool hasZ)
void ymdhms2ydmsec(int yy, int mm, int dd, int hh, int mn, int sc, int32_t *year, int32_t *day, int32_t *msec)
Definition: ydhms2ydmsec.c:3
double yds2unix_(int16_t *year, int16_t *day, double *secs)
Definition: yds2unix.c:34
int leapseconds_since_1993(double tai93time)
Definition: leapsecond.c:58
double tai58_to_unix(double tai58)
Definition: yds2tai.c:29
char * unix2isodate(double dtime, char zone)
Definition: unix2isodate.c:10
void isodate2ydmsec(char *date, int32_t *year, int32_t *day, int32_t *msec)
Definition: date2ydmsec.c:20
int32_t idy
Definition: atrem_corl1.h:161
void unix2ymdhms(double usec, int16_t *year, int16_t *mon, int16_t *day, int16_t *hour, int16_t *min, double *sec)
Definition: unix2ymdhms.c:8
int32_t iyr
Definition: atrem_corl1.h:161
const char * unix2udunits_c(double unixtime, int hasZ)
Definition: aerosol.c:136
int ccsds_to_yds(uint8_t *cctime, int32_t *iyear, int32_t *iday, double *sec)
Definition: ccsds_to_yds.c:5
time_t gmt_offset(void)
Definition: gmt_offset.c:8
double now(void)
Definition: HISTORY.txt:361
double isodate2unix(const char *isodate)
Definition: unix2isodate.c:61