common/uilib.py
branchtls-sprint
changeset 1016 26387b836099
parent 985 6a25c58a1c23
child 1132 96752791c2b6
--- a/common/uilib.py	Mon Mar 09 12:12:53 2009 +0100
+++ b/common/uilib.py	Tue Mar 10 11:35:52 2009 +0100
@@ -12,13 +12,11 @@
 import csv
 import decimal
 import re
+from datetime import datetime, date, timedelta
 from urllib import quote as urlquote
 from cStringIO import StringIO
 from copy import deepcopy
 
-
-from mx.DateTime import DateTimeType, DateTimeDeltaType
-
 from logilab.common.textutils import unormalize
 from logilab.mtconverter import html_escape, html_unescape
 
@@ -509,10 +507,10 @@
         ret = function(*args, **kwargs)
         if isinstance(ret, decimal.Decimal):
             ret = float(ret)
-        elif isinstance(ret, DateTimeType):
+        elif isinstance(ret, (date, datetime)):
             ret = ret.strftime('%Y-%m-%d %H:%M')
-        elif isinstance(ret, DateTimeDeltaType):
-            ret = ret.seconds
+        elif isinstance(ret, timedelta):
+            ret = (ret.days * 24*60*60) + ret.seconds
         try:
             return simplejson.dumps(ret)
         except TypeError: