dabo Commit
Revision 2756
Date: 2007-01-29 14:38:48 -0800 (Mon, 29 Jan 2007)
Author: Paul

Changed:
U   trunk/dabo/lib/dates.py

Log:
Added function dabo.lib.dates.goDate(), since Python's date objects don't
have such functionality yet.


Diff:
Modified: trunk/dabo/lib/dates.py
===================================================================
--- trunk/dabo/lib/dates.py     2007-01-29 05:49:48 UTC (rev 2755)
+++ trunk/dabo/lib/dates.py     2007-01-29 22:38:48 UTC (rev 2756)
@@ -4,6 +4,7 @@
 """
 import datetime
 import re
+import time
 
 _dregex = {}
 _dtregex = {}
@@ -190,6 +191,15 @@
        return ret
 
 
+def goDate(date_exp, days):
+       """Given a datetime.date expression, return the date that is <days> 
away."""
+       now = time.time()
+       one_day = 60*60*24
+       offset = (one_day * days)
+       new_time = time.localtime(now + offset)
+       return datetime.date(new_time[0], new_time[1], new_time[2])
+
+
 if __name__ == "__main__":
        print "testing converting strings to dates:"
        formats = ["ISO8601", "YYYYMMDD", "YYMMDD", "MMDD"]




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to