commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r7680 - in trunk/gnue-common/src/datasources/drivers: DBSIG2 sql/


From: reinhard
Subject: [gnue] r7680 - in trunk/gnue-common/src/datasources/drivers: DBSIG2 sql/maxdb
Date: Mon, 4 Jul 2005 15:30:04 -0500 (CDT)

Author: reinhard
Date: 2005-07-04 15:30:02 -0500 (Mon, 04 Jul 2005)
New Revision: 7680

Modified:
   trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py
   trunk/gnue-common/src/datasources/drivers/sql/maxdb/maxdb.py
Log:
Use Microseconds as parameter for _createTime_ and _createTimestamp_ instead of
a string with the fractional part of seconds: the fractional part can also be
something like 6.08e-05.


Modified: trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py      
2005-07-04 11:20:12 UTC (rev 7679)
+++ trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py      
2005-07-04 20:30:02 UTC (rev 7680)
@@ -126,33 +126,28 @@
          isinstance (value, datetime.datetime):
 
       second = value.second
-      flsecs = hasattr (value, 'microsecond') and value.microsecond or 0
+      microsecond = hasattr (value, 'microsecond') and value.microsecond or 0
 
       if isinstance (second, float):
-        flsecs = int (("%s" % (second - int (second))) [2:])
+        microsecond = int ((second - int (second)) * 1000000)
         second = int (second)
 
-      if self._std_datetime_:
-        flsecs = int (("%s" % flsecs) [:6].ljust (6, '0'))
-
       return self._createTimestamp_ (value.year, value.month, value.day,
-                                      value.hour, value.minute, second, flsecs)
+                                      value.hour, value.minute, second,
+                                      microsecond)
 
     elif isinstance (value, mx.DateTime.DateTimeDeltaType) or \
          isinstance (value, datetime.time):
 
       second = value.second
-      flsecs = hasattr (value, 'microsecond') and value.microsecond or 0
+      microsecond = hasattr (value, 'microsecond') and value.microsecond or 0
 
       if isinstance (second, float):
-        flsecs = int (("%s" % (second - int (second))) [2:])
+        microsecond = int ((second - int (second)) * 1000000)
         second = int (second)
 
-      if self._std_datetime_:
-        flsecs = int (("%s" % flsecs) [:6].ljust (6, '0'))
+      return self._createTime_ (value.hour, value.minute, second, microsecond)
 
-      return self._createTime_ (value.hour, value.minute, second, flsecs)
-
     elif isinstance (value, datetime.date):
       return self._driver.Date (value.year, value.month, value.day)
 
@@ -435,19 +430,22 @@
   # Create an apropriate timestamp object for the given values
   # ---------------------------------------------------------------------------
 
-  def _createTimestamp_ (self, year, month, day, hour, minute, secs, fsec = 0):
+  def _createTimestamp_ (self, year, month, day, hour, minute, secs, msec = 0):
     """
     Create a timestamp object for the given point in time.
 
-    @param secs: whole seconds (integer)
-    @param fsec: fractional part of seconds. If _std_datetime_ is True, this
-      will be interpreted as microseconds and as such given to the Timestamp
-      constructor of the driver.
+    @param year: Year number
+    @param year: Month number (1 - 12)
+    @param day: Day of the month (1 - 31)
+    @param hour: Hour (0 - 23)
+    @param minute: Minute (0 - 59)
+    @param secs: Whole seconds (integer)
+    @param msec: Microseconds (integer)
 
     returns: a timestamp object created by the driver's Timestamp constructor
     """
 
-    psec = float ("%s.%s" % (secs, fsec))
+    psec = secs + msec / 1000000
 
     if self._std_datetime_:
       return self._driver.Timestamp (year, month, day, hour, minute, secs, 
fsec)
@@ -460,19 +458,19 @@
   # Create an apropriate time object for the given values
   # ---------------------------------------------------------------------------
 
-  def _createTime_ (self, hour, minute, second, fsec = 0):
+  def _createTime_ (self, hour, minute, second, msec = 0):
     """
     Create a time object for the given point in time.
 
-    @param second: whole seconds (integer)
-    @param fsec: fractional part of seconds. If _std_datetime_ is True, this
-      will be interpreted as microseconds and as such given to the Time
-      constructor of the driver.
+    @param hour: Hour (0 - 23)
+    @param minute: Minute (0 - 59)
+    @param secs: Whole seconds (integer)
+    @param msec: Microseconds (integer)
 
     returns: a time object created by the driver's Time constructor
     """
 
-    psec = float ("%s.%s" % (second, fsec))
+    psec = secs + msec / 1000000
 
     if self._std_datetime_:
       return self._driver.Time (hour, minute, second, fsec)

Modified: trunk/gnue-common/src/datasources/drivers/sql/maxdb/maxdb.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/maxdb/maxdb.py        
2005-07-04 11:20:12 UTC (rev 7679)
+++ trunk/gnue-common/src/datasources/drivers/sql/maxdb/maxdb.py        
2005-07-04 20:30:02 UTC (rev 7680)
@@ -168,6 +168,6 @@
 
   # ---------------------------------------------------------------------------
 
-  def _createTime_ (self, hour, minute, second, fsecs = 0):
+  def _createTime_ (self, hour, minute, second, msecs = 0):
 
     return self._driver.Time (hour, minute, second)





reply via email to

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