--- a/utils.py Tue Feb 10 23:59:56 2009 +0200
+++ b/utils.py Wed Feb 11 00:33:21 2009 +0200
@@ -67,13 +67,27 @@
"""
timestamp_str -> pytz.utc datetime.datetime
"""
-
- return datetime.datetime.utcfromtimestamp(int(timestamp_str)).replace(tzinfo=pytz.utc)
+
+ return from_utc_timestamp(int(timestamp_str))
def build (self, dtz) :
"""
pytz.utc datetime.datetime -> timestamp_str
"""
+
+ return str(to_utc_timestamp(dtz))
- return str(calendar.timegm(dtz.utctimetuple()))
+def from_utc_timestamp (timestamp) :
+ """
+ Converts a UNIX timestamp into a datetime.datetime
+ """
+ return datetime.datetime.utcfromtimestamp(timestamp).replace(tzinfo=pytz.utc)
+
+def to_utc_timestamp (dt) :
+ """
+ Converts a datetime.datetime into a UNIX timestamp
+ """
+
+ return calendar.timegm(dt.utctimetuple())
+