summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjortel <devnull@localhost>2009-12-23 19:59:14 +0000
committerjortel <devnull@localhost>2009-12-23 19:59:14 +0000
commit0e6e5f2f592abe06c66b392b7ea0040fcd82f513 (patch)
treeb81cc8789e5871c996be3e3f9e91a34264f9f33f
parent2fc3d60c9fd0aac7d4552bd685a4642afa1c07d5 (diff)
downloadsuds-0e6e5f2f592abe06c66b392b7ea0040fcd82f513.tar.gz
Handle overflow errors when trying to convert dates such as: 0001-01-01T00:00:00.000Z.
-rw-r--r--suds/__init__.py2
-rw-r--r--suds/sax/date.py10
-rw-r--r--tests/builtin.py19
3 files changed, 26 insertions, 5 deletions
diff --git a/suds/__init__.py b/suds/__init__.py
index 7e4c77e..ce6d5de 100644
--- a/suds/__init__.py
+++ b/suds/__init__.py
@@ -29,7 +29,7 @@ import sys
#
__version__ = '0.3.9'
-__build__="(beta) R632-20091221"
+__build__="(beta) R633-20091223"
#
# Exceptions
diff --git a/suds/sax/date.py b/suds/sax/date.py
index 7f66429..f07cf84 100644
--- a/suds/sax/date.py
+++ b/suds/sax/date.py
@@ -297,13 +297,17 @@ class DateTime(Date,Time):
"""
Adjust for TZ offset.
"""
- if hasattr(self, 'offset'):
- tz = Timezone()
- delta = Timezone.adjustment(self.offset)
+ if not hasattr(self, 'offset'):
+ return
+ tz = Timezone()
+ delta = Timezone.adjustment(self.offset)
+ try:
d = ( self.datetime + delta )
self.datetime = d
self.date = d.date()
self.time = d.time()
+ except OverflowError:
+ log.warn('"%s" caused overflow, not-adjusted', self.datetime)
def __str__(self):
return unicode(self)
diff --git a/tests/builtin.py b/tests/builtin.py
index 8ebcf78..31ca3c3 100644
--- a/tests/builtin.py
+++ b/tests/builtin.py
@@ -14,10 +14,14 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# written by: Jeff Ortel ( jortel@redhat.com )
-
+import sys
+sys.path.append('../')
from suds.sax.date import Timezone as Tz
from suds.xsd.sxbuiltin import *
from unittest import TestCase
+from tests import *
+
+setup_logging()
class Date(XDate):
@@ -234,6 +238,19 @@ class DateTimeTest(TestCase):
t = xdt.translate(s)
self.assertEqual(t, ref)
+ def testOverflow(self):
+ ref = dt.datetime(1, 1, 1, 0, 0, 0)
+ s = '%.4d-%.2d-%.2dT%.2d:%.2d:%.2dZ' \
+ % (ref.year,
+ ref.month,
+ ref.day,
+ ref.hour,
+ ref.minute,
+ ref.second)
+ xdt = DateTime()
+ t = xdt.translate(s)
+ self.assertEqual(t, ref)
+
def testSimpleWithMicrosecond(self):
ref = dt.datetime(1941, 12, 7, 10, 30, 22, 454)
s = '%.4d-%.2d-%.2dT%.2d:%.2d:%.2d.%.4d' \