From: Sage Weil Date: Thu, 25 Apr 2019 22:12:50 +0000 (-0500) Subject: include/utime: make default string rendering ISO 8601 conformant X-Git-Tag: v15.1.0~2616^2~14 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=79d8d761cf8fb6a5679d1925f92889c950dc2be4;p=ceph-ci.git include/utime: make default string rendering ISO 8601 conformant - use T separator - include TZ offset Signed-off-by: Sage Weil --- diff --git a/src/include/utime.h b/src/include/utime.h index 5eadcc48f49..ee1bf37da8e 100644 --- a/src/include/utime.h +++ b/src/include/utime.h @@ -299,7 +299,6 @@ public: out << (long)sec() << "." << std::setw(6) << usec(); } else { // this looks like an absolute time. - // aim for http://en.wikipedia.org/wiki/ISO_8601 struct tm bdt; time_t tt = sec(); gmtime_r(&tt, &bdt); @@ -325,19 +324,21 @@ public: out << (long)sec() << "." << std::setw(6) << usec(); } else { // this looks like an absolute time. - // aim for http://en.wikipedia.org/wiki/ISO_8601 + // conform to http://en.wikipedia.org/wiki/ISO_8601 struct tm bdt; time_t tt = sec(); localtime_r(&tt, &bdt); out << std::setw(4) << (bdt.tm_year+1900) // 2007 -> '07' << '-' << std::setw(2) << (bdt.tm_mon+1) << '-' << std::setw(2) << bdt.tm_mday - << ' ' + << 'T' << std::setw(2) << bdt.tm_hour << ':' << std::setw(2) << bdt.tm_min << ':' << std::setw(2) << bdt.tm_sec; out << "." << std::setw(6) << usec(); - //out << '_' << bdt.tm_zone; + char buf[32] = { 0 }; + strftime(buf, sizeof(buf), "%z", &bdt); + out << buf; } out.fill(oldfill); out.unsetf(std::ios::right);