]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
utime: extend utime parsing
authorYehuda Sadeh <yehuda@inktank.com>
Sat, 10 May 2014 00:01:44 +0000 (17:01 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Wed, 28 Jan 2015 00:25:00 +0000 (16:25 -0800)
Since we sometimes encode it as <sec>.<usec>, also try to parse it using
this format.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/include/utime.h

index 032c7d04ab1909f560582b0a0cb85ead401d57fc..9ec0c48f70d41704504ff63db8b0b5056aa0dda7 100644 (file)
@@ -278,7 +278,18 @@ public:
         }
       }
     } else {
-      return -EINVAL;
+      int sec, usec;
+      int r = sscanf(date.c_str(), "%d.%d", &sec, &usec);
+      if (r != 2) {
+        return -EINVAL;
+      }
+
+      time_t tt = sec;
+      gmtime_r(&tt, &tm);
+
+      if (nsec) {
+        *nsec = usec * 1000;
+      }
     }
     time_t t = timegm(&tm);
     if (epoch)