--- a/src/modules/misc.py Fri Aug 01 23:55:39 2008 -0700
+++ b/src/modules/misc.py Fri Aug 01 23:57:44 2008 -0700
@@ -35,12 +35,23 @@
import urlparse
import sys
import zlib
-
+import time
+import calendar
import pkg.urlhelpers as urlhelpers
import pkg.portable as portable
from pkg.client.imagetypes import img_type_names, IMG_NONE
from pkg import VERSION
+def time_to_timestamp(t):
+ """ convert seconds since epoch to %Y%m%dT%H%M%SZ format"""
+ # XXX optimize?
+ return time.strftime("%Y%m%dT%H%M%SZ", time.gmtime(t))
+
+def timestamp_to_time(ts):
+ """ convert %Y%m%dT%H%M%SZ format to seconds since epoch"""
+ # XXX optimize?
+ return calendar.timegm(time.strptime(ts, "%Y%m%dT%H%M%SZ"))
+
def hash_file_name(f):
"""Return the two-level path fragment for the given filename, which is
assumed to be a content hash of at least 8 distinct characters."""