2
0
Эх сурвалжийг харах

Python 2.5 compatible timestamp parsing

Jonas Borgström 14 жил өмнө
parent
commit
43cb73603b
1 өөрчлөгдсөн 3 нэмэгдсэн , 2 устгасан
  1. 3 2
      darc/archive.py

+ 3 - 2
darc/archive.py

@@ -1,5 +1,5 @@
 from __future__ import with_statement
-from datetime import datetime
+from datetime import datetime, timedelta
 from getpass import getuser
 import msgpack
 import os
@@ -47,7 +47,8 @@ class Archive(object):
     @property
     def ts(self):
         """Timestamp of archive creation in UTC"""
-        return datetime.strptime(self.metadata['time'], '%Y-%m-%dT%H:%M:%S.%f')
+        t, f = self.metadata['time'].split('.', 1)
+        return datetime.strptime(t, '%Y-%m-%dT%H:%M:%S') + timedelta(int(f) / 100)
 
     def get_chunks(self):
         for id in self.metadata['chunks_ids']: