]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
util/time_format: new routine to parse dates like 2009-03-18, switch expirer to use...
authorBrian Warner <warner@allmydata.com>
Thu, 19 Mar 2009 00:58:14 +0000 (17:58 -0700)
committerBrian Warner <warner@allmydata.com>
Thu, 19 Mar 2009 00:58:14 +0000 (17:58 -0700)
docs/proposed/garbage-collection.txt
src/allmydata/test/test_storage.py
src/allmydata/util/time_format.py
src/allmydata/web/storage.py

index 51998d677d9dcce6b5939937b273afa4c7632212..758e191993b9c50d291ddf9ab0b0c6f5730bf5ed 100644 (file)
@@ -169,9 +169,9 @@ expire.cutoff_date = (date string, required if mode=date-cutoff)
  create/renew timestamp is older than the cutoff date. This string will be a
  date in the following format:
 
-  16-Jan-2009
-  02-Feb-2008
-  25-Dec-2007
+  2009-01-16   (January 16th, 2009)
+  2008-02-02
+  2007-12-25
 
  The actual cutoff time shall be midnight UTC at the beginning of the given
  day. Lease timers should naturally be generous enough to not depend upon
index f3452b43b1b2d095381340e5627e5988b8bccbf3..39e8806bb0f14d816b2d487cabb1b67e14d755e7 100644 (file)
@@ -2020,7 +2020,7 @@ class LeaseCrawler(unittest.TestCase, pollmixin.PollMixin, WebRenderingMixin):
             s = remove_tags(html)
             self.failUnlessIn("Expiration Enabled:"
                               " expired leases will be removed", s)
-            date = time.strftime("%d-%b-%Y", time.gmtime(then))
+            date = time.strftime("%Y-%m-%d", time.gmtime(then))
             self.failUnlessIn("Leases created or last renewed before %s"
                               " will be considered expired." % date, s)
             self.failUnlessIn(" recovered: 2 shares, 2 buckets (1 mutable / 1 immutable), ", s)
@@ -2164,6 +2164,10 @@ class LeaseCrawler(unittest.TestCase, pollmixin.PollMixin, WebRenderingMixin):
         self.failUnless("no unit (like day, month, or year) in '2kumquats'"
                         in str(e), str(e))
 
+    def test_parse_date(self):
+        p = time_format.parse_date
+        self.failUnlessEqual(p("2009-03-18"), 1237334400)
+
     def test_limited_history(self):
         basedir = "storage/LeaseCrawler/limited_history"
         fileutil.make_dirs(basedir)
index 0281b6d7c27c07765ddb287eb8c82012d19a740f..0bc3928062274e13fc0f0ced230e4286963c0892 100644 (file)
@@ -58,3 +58,9 @@ def parse_duration(s):
         raise ValueError("no unit (like day, month, or year) in '%s'" % orig)
     s = s.strip()
     return int(s) * unit
+
+def parse_date(s):
+    # return seconds-since-epoch for the UTC midnight that starts the given
+    # day
+    return iso_utc_time_to_localseconds(s + "T00:00:00")
+
index 56db9026989cc05c351c56f20f2be850f049d2bb..b35839ea6ccfb5292ab6a69c5e70f3f7f9880bbe 100644 (file)
@@ -138,8 +138,8 @@ class StorageStatus(rend.Page):
                         "will be considered expired."
                         % abbreviate_time(lc.override_lease_duration)]
         else:
-            assert lc.mode == "date-cutoff"
-            date = time.strftime("%d-%b-%Y", time.gmtime(lc.date_cutoff))
+            assert lc.mode == "cutoff-date"
+            date = time.strftime("%Y-%m-%d", time.gmtime(lc.cutoff_date))
             ctx.tag["Leases created or last renewed before %s "
                     "will be considered expired." % date]
         if len(lc.mode) > 2: