]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
include/utime: make default string rendering ISO 8601 conformant
authorSage Weil <sage@redhat.com>
Thu, 25 Apr 2019 22:12:50 +0000 (17:12 -0500)
committerSage Weil <sage@redhat.com>
Wed, 29 May 2019 19:12:01 +0000 (14:12 -0500)
- use T separator
- include TZ offset

Signed-off-by: Sage Weil <sage@redhat.com>
src/include/utime.h

index 5eadcc48f49dcde5bc7a7573d025b7aa67ba206b..ee1bf37da8ec47f3f2891e87a8e0f44e2c31f7f3 100644 (file)
@@ -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);