dabo Commit
Revision 3891
Date: 2008-01-18 13:01:52 -0800 (Fri, 18 Jan 2008)
Author: Paul
Trac: http://svn.dabodev.com/trac/dabo/changeset/3891
Changed:
U trunk/dabo/lib/dates.py
Log:
I didn't realize that datetime.strftime() differed in behavior from
time.strftime(). Thanks John Fabiani for reporting the problem with
datetime.strftime() that doesn't like years lower than 1900.
Diff:
Modified: trunk/dabo/lib/dates.py
===================================================================
--- trunk/dabo/lib/dates.py 2008-01-18 20:07:01 UTC (rev 3890)
+++ trunk/dabo/lib/dates.py 2008-01-18 21:01:52 UTC (rev 3891)
@@ -86,14 +86,14 @@
return re.compile(exp % elements)
-def getStringFromDate(dateVal):
+def getStringFromDate(d):
"""Given a datetime.date, convert to string in dabo.settings.dateFormat
style."""
- dateFormat = dabo.settings.dateFormat
- if dateFormat is None:
+ fmt = dabo.settings.dateFormat
+ if fmt is None:
# Delegate formatting to the time module, which will take the
# user's locale into account.
- dateFormat = "%x"
- return dateVal.strftime(dateFormat)
+ fmt = "%x"
+ return time.strftime(fmt, (d.year, d.month, d.day, 0, 0, 0, 0, 0, 0))
def getDateFromString(strVal, formats=None):
@@ -150,14 +150,14 @@
return ret
-def getStringFromDateTime(dateTimeVal):
+def getStringFromDateTime(dt):
"""Given a datetime.datetime, convert to string in
dabo.settings.dateTimeFormat style."""
- dateTimeFormat = dabo.settings.dateTimeFormat
- if dateTimeFormat is None:
+ fmt = dabo.settings.dateTimeFormat
+ if fmt is None:
# Delegate formatting to the time module, which will take the
# user's locale into account.
- dateTimeFormat = "%x %X"
- return dateTimeVal.strftime(dateTimeFormat)
+ fmt = "%x %X"
+ return time.strftime(fmt, (dt.year, dt.month, dt.day, dt.hour,
dt.minute, dt.second, dt.microsecond, 0, 0))
def getDateTimeFromString(strVal, formats=None):
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/dabo-dev/[EMAIL PROTECTED]