Merge pull request #124 from maikebing/master

Modify  json's date to Json standard time format ISO-8601
This commit is contained in:
slguan 2019-08-10 23:09:31 +08:00 committed by GitHub
commit 0e57b621b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -266,11 +266,11 @@ void httpJsonTimestamp(JsonBuf* buf, int64_t t) {
struct tm* ptm;
time_t tt = t / 1000;
ptm = localtime(&tt);
int length = (int)strftime(ts, 30, "%Y-%m-%d %H:%M:%S", ptm);
int length = (int)strftime(ts, 30, "%Y-%m-%dT%H:%M:%S", ptm);
snprintf(ts+length, MAX_NUM_STR_SZ, ".%03ld", t % 1000);
snprintf(ts+length, MAX_NUM_STR_SZ, ".%03ldZ", t % 1000);
httpJsonString(buf, ts, length + 4);
httpJsonString(buf, ts, length + 5);
}
void httpJsonInt(JsonBuf* buf, int num) {
@ -422,4 +422,4 @@ void httpJsonPairStatus(JsonBuf* buf, int code) {
httpJsonPair(buf, "desc", 4, tsError[code], (int)strlen(tsError[code]));
}
}
}
}