Menu

#43 Invalid microsecond conversion using DateTimeAsPython

0.39
open
nobody
None
5
2013-10-08
2013-10-08
No

When using DateTimeAsPython for my output map, I found that the microsecond value in datetime.datetime was 1000 times the value stored in the database. here's a patch:

--- Sybase.py   (revision xxx)
+++ Sybase.py   (working copy)
@@ -197,10 +197,10 @@
     DateTimeAsPython = {
         CS_DATETIME_TYPE: lambda val: datetime.datetime(val.year, val.month + 1, val.day,
                                                         val.hour, val.minute,
-                                                        val.second, val.msecond * 1000),
+                                                        val.second, val.msecond),
         CS_DATETIME4_TYPE: lambda val: datetime.datetime(val.year, val.month + 1, val.day,
                                                          val.hour, val.minute,
-                                                         val.second, val.msecond * 1000) }
+                                                         val.second, val.msecond) }
     if _have_cs_date_type:
         DateTimeAsPython.update({
             CS_DATE_TYPE: lambda val: datetime.date(val.year, val.month + 1, val.day) })

Additional note: DateTimeAsPython also raises an error if the datetime field is NULL, probably not the desired behavior.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.