Mercurial > p > roundup > code
diff roundup/date.py @ 2703:770f9fa94c6a maint-0.7
merge from HEAD
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 29 Sep 2004 07:31:32 +0000 |
| parents | 5080ca961b2e |
| children | 8a4a2e135a73 |
line wrap: on
line diff
--- a/roundup/date.py Tue Sep 14 22:03:43 2004 +0000 +++ b/roundup/date.py Wed Sep 29 07:31:32 2004 +0000 @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: date.py,v 1.68.2.2 2004-07-04 09:08:55 richard Exp $ +# $Id: date.py,v 1.68.2.3 2004-09-29 07:31:32 richard Exp $ """Date, time and time interval handling. """ @@ -25,6 +25,12 @@ from types import * from i18n import _ +try: + import datetime + have_datetime = 1 +except: + have_datetime = 0 + def _add_granularity(src, order, value = 1): '''Increment first non-None value in src dictionary ordered by 'order' parameter @@ -121,6 +127,11 @@ if type(spec) == type(''): self.set(spec, offset=offset, add_granularity=add_granularity) return + elif have_datetime and isinstance(spec, datetime.datetime): + # Python 2.3+ datetime object + y,m,d,H,M,S,x,x,x = spec.timetuple() + S += spec.microsecond/1000000. + spec = (y,m,d,H,M,S,x,x,x) elif hasattr(spec, 'tuple'): spec = spec.tuple() elif isinstance(spec, Date):
