]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
include/utime: add parse() method
authorSage Weil <sage@redhat.com>
Tue, 5 Jun 2018 18:57:17 +0000 (13:57 -0500)
committerSage Weil <sage@redhat.com>
Mon, 11 Jun 2018 12:28:50 +0000 (07:28 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/include/utime.h

index bc2db0b99e1521abaf9375d093dd716099776c1a..a0dba3048c2887ca70fdd0fa28dd5a99837866ef 100644 (file)
@@ -435,6 +435,16 @@ public:
 
     return 0;
   }
+
+  bool parse(const string& s) {
+    uint64_t epoch, nsec;
+    int r = parse_date(s, &epoch, &nsec);
+    if (r < 0) {
+      return false;
+    }
+    *this = utime_t(epoch, nsec);
+    return true;
+  }
 };
 WRITE_CLASS_ENCODER(utime_t)
 WRITE_CLASS_DENC(utime_t)