commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r7679 - trunk/gnue-common/src/datasources/drivers/DBSIG2


From: johannes
Subject: [gnue] r7679 - trunk/gnue-common/src/datasources/drivers/DBSIG2
Date: Mon, 4 Jul 2005 06:20:13 -0500 (CDT)

Author: johannes
Date: 2005-07-04 06:20:12 -0500 (Mon, 04 Jul 2005)
New Revision: 7679

Modified:
   trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py
Log:
Fixed treatment of fractional seconds, added docstrings


Modified: trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py      
2005-07-03 17:14:08 UTC (rev 7678)
+++ trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py      
2005-07-04 11:20:12 UTC (rev 7679)
@@ -60,9 +60,12 @@
     module does not return a correct value for cursor.rowcount.
   @cvar _named_as_sequence_: If paramstyle = 'named' pass parameters as
     sequence (True) or as mapping (False). Can be overwritten by descendants.
+  @cvar _std_datetime_: If True, the driver will use python's (2.3+) datetime
+    types for time and timestamp values. If so, the constructors Timestamp and
+    Time will be called with an extra argument for microseconds.
   """
 
-  _resultSetClass_ = ResultSet
+  _resultSetClass_    = ResultSet
 
   _drivername_        = None            # DBSIG2 compatible driver module
   _boolean_false_     = False           # value to pass for boolean FALSE
@@ -130,7 +133,7 @@
         second = int (second)
 
       if self._std_datetime_:
-        flsecs = int (("%s" % flsecs) [:6])
+        flsecs = int (("%s" % flsecs) [:6].ljust (6, '0'))
 
       return self._createTimestamp_ (value.year, value.month, value.day,
                                       value.hour, value.minute, second, flsecs)
@@ -146,7 +149,7 @@
         second = int (second)
 
       if self._std_datetime_:
-        flsecs = int (("%s" % flsecs) [:6])
+        flsecs = int (("%s" % flsecs) [:6].ljust (6, '0'))
 
       return self._createTime_ (value.hour, value.minute, second, flsecs)
 
@@ -429,6 +432,56 @@
 
 
   # ---------------------------------------------------------------------------
+  # Create an apropriate timestamp object for the given values
+  # ---------------------------------------------------------------------------
+
+  def _createTimestamp_ (self, year, month, day, hour, minute, secs, fsec = 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.
+
+    returns: a timestamp object created by the driver's Timestamp constructor
+    """
+
+    psec = float ("%s.%s" % (secs, fsec))
+
+    if self._std_datetime_:
+      return self._driver.Timestamp (year, month, day, hour, minute, secs, 
fsec)
+
+    else:
+      return self._driver.Timestamp (year, month, day, hour, minute, psec)
+
+
+  # ---------------------------------------------------------------------------
+  # Create an apropriate time object for the given values
+  # ---------------------------------------------------------------------------
+
+  def _createTime_ (self, hour, minute, second, fsec = 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.
+
+    returns: a time object created by the driver's Time constructor
+    """
+
+    psec = float ("%s.%s" % (second, fsec))
+
+    if self._std_datetime_:
+      return self._driver.Time (hour, minute, second, fsec)
+
+    else:
+      return self._driver.Time (hour, minute, psec)
+
+
+  # ---------------------------------------------------------------------------
   # Implementations of virtual methods
   # ---------------------------------------------------------------------------
 
@@ -525,29 +578,3 @@
     gDebug (3, 'DBSIG2 Close')
     if self._native:
       self._native.close ()
-
-
-  # ---------------------------------------------------------------------------
-
-  def _createTimestamp_ (self, year, month, day, hour, minute, secs, fsec = 0):
-
-    psec = float ("%s.%s" % (secs, fsec))
-
-    if self._std_datetime_:
-      return self._driver.Timestamp (year, month, day, hour, minute, secs, 
fsec)
-
-    else:
-      return self._driver.Timestamp (year, month, day, hour, minute, psec)
-
-
-  # ---------------------------------------------------------------------------
-
-  def _createTime_ (self, hour, minute, second, fsec = 0):
-
-    psec = float ("%s.%s" % (second, fsec))
-
-    if self._std_datetime_:
-      return self._driver.Time (hour, minute, second, fsec)
-
-    else:
-      return self._driver.Time (hour, minute, psec)





reply via email to

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