Go to the documentation of this file.
13 static char string[30];
17 return "Undefined time";
20 itime = (time_t) dtime;
26 ts = localtime(&itime);
29 fprintf(
stderr,
"-W- %s line %d: ", __FILE__, __LINE__);
30 fprintf(
stderr,
"Bad timezone argument passed to unix2isodate().\n");
35 int fracSec = floor(1000 * (dtime - itime) + 0.0005);
36 if (fracSec == 1000) {
41 sprintf(
string,
"%d-%02d-%02dT%02d:%02d:%02d.%03.0f", ts->tm_year + 1900, ts->tm_mon + 1,
42 ts->tm_mday, ts->tm_hour, ts->tm_min, ts->tm_sec, (
float) fracSec);
49 sprintf(tzone,
"%+03d", (
int) ts->tm_gmtoff / 3600);
50 strcat(
string, tzone);
53 fprintf(
stderr,
"-W- %s line %d: ", __FILE__, __LINE__);
54 fprintf(
stderr,
"Bad timezone argument passed to unix2isodate().\n");
63 strptime(isodate,
"%Y-%m-%dT%H:%M:%S", &trec);
64 double secSince = mktime(&trec) -
gmt_offset();
65 char* ptr = strchr(isodate,
'.');
67 double fracsecs = atof(ptr);
73 void isodate2ymds(
const char* isodate, int16_t *year, int16_t *month, int16_t *
day,
double *sec) {
74 if (isodate ==
NULL) {
83 if (strptime(isodate,
"%Y-%m-%dT%H:%M:%S", &trec) ==
NULL) {
90 *year = trec.tm_year + 1900;
91 *month = trec.tm_mon + 1;
93 *sec = trec.tm_hour * 3600 + trec.tm_min * 60 + trec.tm_sec;
96 char* ptr = strchr(isodate,
'.');
98 double fracsecs = atof(ptr);
void isodate2ymds(const char *isodate, int16_t *year, int16_t *month, int16_t *day, double *sec)
char * unix2isodate(double dtime, char zone)
double isodate2unix(const char *isodate)