Think harder about timestamps. Just save seconds since the epoch as a float.

This commit is contained in:
Aldo Cortesi 2011-03-09 12:18:08 +13:00
parent 765871bd11
commit 897c4bfc52

View File

@ -16,14 +16,15 @@ import re, os, subprocess, datetime, textwrap, errno, sys, time, pytz
def timestamp():
d = datetime.datetime.utcnow()
return list(d.timetuple())
"""
Returns a serializable UTC timestamp.
"""
return time.time()
def format_timestamp(s):
s = time.struct_time(s)
s = time.localtime(s)
d = datetime.datetime.fromtimestamp(time.mktime(s))
d = d - datetime.timedelta(seconds=time.altzone)
return d.strftime("%Y-%m-%d %H:%M:%S")