commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r7676 - in trunk/gnue-common: src/datasources tests


From: johannes
Subject: [gnue] r7676 - in trunk/gnue-common: src/datasources tests
Date: Sat, 2 Jul 2005 13:38:50 -0500 (CDT)

Author: johannes
Date: 2005-07-02 13:38:49 -0500 (Sat, 02 Jul 2005)
New Revision: 7676

Modified:
   trunk/gnue-common/src/datasources/GConditions.py
   trunk/gnue-common/tests/datasources_GConditions.py
Log:
Added unification for datetime.timedelta and datetime.time


Modified: trunk/gnue-common/src/datasources/GConditions.py
===================================================================
--- trunk/gnue-common/src/datasources/GConditions.py    2005-07-02 18:17:47 UTC 
(rev 7675)
+++ trunk/gnue-common/src/datasources/GConditions.py    2005-07-02 18:38:49 UTC 
(rev 7676)
@@ -1568,7 +1568,8 @@
 
           if isinstance (chkValue, datetime.time):
             micro = int (("%s" % (new.second - int (new.second))) [2:8])
-            newValue = datetime.time (new.hour, new.minute, new.second, micro)
+            newValue = datetime.time (new.hour, new.minute, int (new.second),
+                                      micro)
 
           elif isinstance (chkValue, datetime.date):
             newValue = datetime.date (new.year, new.month, new.day)
@@ -1576,7 +1577,7 @@
           elif isinstance (chkValue, datetime.datetime):
             micro = int (("%s" % (new.second - int (new.second))) [2:8])
             newValue = datetime.datetime (new.year, new.month, new.day,
-                new.hour, new.minute, new.second, micro)
+                new.hour, new.minute, int (new.second), micro)
 
           else:
             newValue = new
@@ -1662,6 +1663,8 @@
 
       elif isinstance (chkValue, mx.DateTime.DateTimeType):
         newValue = datetime.date (oldValue.year, oldValue.month, oldValue.day)
+      else:
+        raise ConversionRuleError, (v1, v2)
 
     elif isinstance (v1, mx.DateTime.DateTimeType) or \
          isinstance (v2, mx.DateTime.DateTimeType):
@@ -1680,6 +1683,8 @@
         newValue = datetime.datetime (oldValue.year, oldValue.month,
             oldValue.day, oldValue.hour, oldValue.minute, int 
(oldValue.second),
             micro)
+      else:
+        raise ConversionRuleError, (v1, v2)
 
     elif isinstance (v1, mx.DateTime.DateTimeDeltaType) or \
          isinstance (v2, mx.DateTime.DateTimeDeltaType):
@@ -1694,7 +1699,24 @@
         micro = int (("%s" % (oldValue.second - int (oldValue.second))) [2:8])
         newValue = datetime.time (oldValue.hour, oldValue.minute,
                                   int (oldValue.second), micro)
+      else:
+        raise ConversionRuleError, (v1, v2)
 
+    elif isinstance (v1, datetime.timedelta) or \
+         isinstance (v2, datetime.timedelta):
+      if isinstance (v1, datetime.timedelta):
+        oldValue = v1
+        chkValue = v2
+      else:
+        oldValue = v2
+        chkValue = v1
+
+      if isinstance (chkValue, datetime.time):
+        newValue = datetime.time (oldValue.seconds / 3600,
+            oldValue.seconds % 3600 / 60, oldValue.seconds % 60,
+            oldValue.microseconds)
+      else:
+        raise ConversionRuleError, (v1, v2)
     else:
       raise ConversionRuleError, (v1, v2)
   

Modified: trunk/gnue-common/tests/datasources_GConditions.py
===================================================================
--- trunk/gnue-common/tests/datasources_GConditions.py  2005-07-02 18:17:47 UTC 
(rev 7675)
+++ trunk/gnue-common/tests/datasources_GConditions.py  2005-07-02 18:38:49 UTC 
(rev 7676)
@@ -238,7 +238,8 @@
         [datetime.datetime.today (), '2004-08-15 15:01:32.124'],
         [datetime.datetime.today ().time (), '2004-08-15 15:01:32.124'],
         [datetime.datetime.today (), mx.DateTime.now ()],
-        [datetime.datetime.today ().time (), mx.DateTime.Time (1, 2, 3.45)]
+        [datetime.datetime.today ().time (), mx.DateTime.Time (1, 2, 3.45)],
+        [mx.DateTime.DateTimeDelta (15), datetime.datetime.today ().time ()]
         ]
         
     self.nogos = [['trash', True], ['atext', 5.43]]
@@ -258,9 +259,7 @@
     # all sequences listed in self.unifications should work fine
     for sequence in self.unifications:
       tset   = sets.Set ()
-      print "SEQ:", sequence
       result = unify (sequence)
-      print "SEQ:", sequence, "==", result
       allowedTypes = 1
 
       for item in result:





reply via email to

[Prev in Thread] Current Thread [Next in Thread]