Commit 314950e0 authored by Claes's avatar Claes Committed by Esteban Blanc

time_AsciiToA() handles different formats

parent 20dfb924
......@@ -1069,9 +1069,23 @@ pwr_tStatus time_AsciiToTm(const char* tstr, struct tm* tmptr)
struct tm tt;
int i;
pwr_tStatus sts;
int monstr = 0;
if (tstr[5] == '-') {
sscanf(tstr, "%02d-%02d-%4d %02d:%02d:%02d", &tt.tm_mday, &tt.tm_mon,
&tt.tm_year, &tt.tm_hour, &tt.tm_min, &tt.tm_sec);
tt.tm_mon--;
}
else if (tstr[4] == '-') {
sscanf(tstr, "%4d-%02d-%02d %02d:%02d:%02d", &tt.tm_year, &tt.tm_mon,
&tt.tm_mday, &tt.tm_hour, &tt.tm_min, &tt.tm_sec);
tt.tm_mon--;
}
else {
sscanf(tstr, "%02d-%3c-%4d %02d:%02d:%02d", &tt.tm_mday, tmpMonStr,
&tt.tm_year, &tt.tm_hour, &tt.tm_min, &tt.tm_sec);
monstr = 1;
}
tmpMonStr[3] = '\0';
tt.tm_year -= 1900;
......@@ -1083,6 +1097,7 @@ pwr_tStatus time_AsciiToTm(const char* tstr, struct tm* tmptr)
tt.tm_isdst = -1;
/* check month */
if (monstr) {
for (cp = tmpMonStr; *cp; cp++)
*cp = toupper(*cp);
......@@ -1093,6 +1108,7 @@ pwr_tStatus time_AsciiToTm(const char* tstr, struct tm* tmptr)
break;
}
}
}
if (EVEN(sts = validateTm(&tt)))
return sts;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment