|
|
@ -17,12 +17,18 @@ size_t scan_iso8601(const char* in,struct timespec* t) { |
|
|
|
unsigned long tmp; |
|
|
|
size_t i; |
|
|
|
if (!(c=in)) return 0; |
|
|
|
if ((i=scan_ulong(c,&tmp))<4 || c[i]!='-') return 0; c+=i+1; x.tm_year=(int)(tmp-1900); |
|
|
|
if (scan_ulong(c,&tmp)!=2 || c[2]!='-') return 0; c+=3; x.tm_mon=(int)(tmp-1); |
|
|
|
if (scan_ulong(c,&tmp)!=2 || c[2]!='T') return 0; c+=3; x.tm_mday=(int)tmp; |
|
|
|
if (scan_ulong(c,&tmp)!=2 || c[2]!=':') return 0; c+=3; x.tm_hour=(int)tmp; |
|
|
|
if (scan_ulong(c,&tmp)!=2 || c[2]!=':') return 0; c+=3; x.tm_min=(int)tmp; |
|
|
|
if (scan_ulong(c,&tmp)!=2) return 0; c+=2; x.tm_sec=(int)tmp; |
|
|
|
if ((i=scan_ulong(c,&tmp))<4 || c[i]!='-') return 0; |
|
|
|
c+=i+1; x.tm_year=(int)(tmp-1900); |
|
|
|
if (scan_ulong(c,&tmp)!=2 || c[2]!='-') return 0; |
|
|
|
c+=3; x.tm_mon=(int)(tmp-1); |
|
|
|
if (scan_ulong(c,&tmp)!=2 || c[2]!='T') return 0; |
|
|
|
c+=3; x.tm_mday=(int)tmp; |
|
|
|
if (scan_ulong(c,&tmp)!=2 || c[2]!=':') return 0; |
|
|
|
c+=3; x.tm_hour=(int)tmp; |
|
|
|
if (scan_ulong(c,&tmp)!=2 || c[2]!=':') return 0; |
|
|
|
c+=3; x.tm_min=(int)tmp; |
|
|
|
if (scan_ulong(c,&tmp)!=2) return 0; |
|
|
|
c+=2; x.tm_sec=(int)tmp; |
|
|
|
if (*c=='.') { |
|
|
|
++c; |
|
|
|
i=scan_ulong(c,&tmp); |
|
|
@ -38,7 +44,11 @@ size_t scan_iso8601(const char* in,struct timespec* t) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#ifdef __MINGW32__ |
|
|
|
x.tm_wday=x.tm_yday=x.tm_isdst=0; |
|
|
|
#else |
|
|
|
x.tm_wday=x.tm_yday=x.tm_isdst=x.tm_gmtoff=0; |
|
|
|
#endif |
|
|
|
#if defined(__dietlibc__) || defined(__GLIBC__) |
|
|
|
t->tv_sec=timegm(&x); |
|
|
|
#elif defined(__MINGW32__) |
|
|
@ -63,7 +73,8 @@ size_t scan_iso8601(const char* in,struct timespec* t) { |
|
|
|
if (*c=='+' || *c=='-') { |
|
|
|
int signum = (*c=='-') - (*c=='+'); |
|
|
|
++c; |
|
|
|
if (scan_ulong(c,&tmp)!=4) return 0; c+=4; |
|
|
|
if (scan_ulong(c,&tmp)!=4) return 0; |
|
|
|
c+=4; |
|
|
|
t->tv_sec+=signum*60*(int)(tmp/100)*60+(int)(tmp%100); |
|
|
|
} else if (*c=='Z') |
|
|
|
++c; |
|
|
|