From ed84534c5b8cf8bd7fd8373e18e65060705f5569 Mon Sep 17 00:00:00 2001 From: Zooko O'Whielacronx Date: Sun, 14 Oct 2007 20:46:51 -0700 Subject: [PATCH] a slightly nicer method of computing our timestamp format --- src/allmydata/node.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/allmydata/node.py b/src/allmydata/node.py index 5b699a91..b01c5e0e 100644 --- a/src/allmydata/node.py +++ b/src/allmydata/node.py @@ -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 -- 2.45.2