]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
a slightly nicer method of computing our timestamp format
authorZooko O'Whielacronx <zooko@zooko.com>
Mon, 15 Oct 2007 03:46:51 +0000 (20:46 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Mon, 15 Oct 2007 03:46:51 +0000 (20:46 -0700)
src/allmydata/node.py

index 5b699a914c0e61582daa9e1a1bab8c370f67fb43..b01c5e0ed1b0a1025538ed4dfd1e8704843f969d 100644 (file)
@@ -1,5 +1,5 @@
 
-import new, os.path, re, time
+import datetime, new, os.path, re
 from base64 import b32decode, b32encode
 
 import twisted
@@ -19,16 +19,14 @@ import foolscap
 ADDR_RE=re.compile("^([1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*)(:([1-9][0-9]*))?$")
 
 
-
 def formatTimeTahoeStyle(self, when):
     # we want UTC timestamps that look like:
     #  2007-10-12 00:26:28.566Z [Client] rnp752lz: 'client running'
-    base = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(when))
-    # now add the milliseconds
-    fraction = when - int(when)
-    suffix = ".%03dZ" % (1000*fraction,)
-    return base + suffix
-
+    d = datetime.datetime.utcfromtimestamp(when)
+    if d.microsecond:
+        return d.isoformat(" ")[:-3]+"Z"
+    else:
+        return d.isoformat(" ") + ".000Z"
 
 class Node(service.MultiService):
     # this implements common functionality of both Client nodes, Introducer