[dataimport] Correctly serialize datetime objects in _create_copyfrom_buffer, closes #3712885 stable
authorVincent Michel <vincent.michel@logilab.fr>
Mon, 07 Apr 2014 08:44:56 +0000
branchstable
changeset 9696 4de6e73f580d
parent 9695 aa982b7c3f2a
child 9697 d96b5e72717c
[dataimport] Correctly serialize datetime objects in _create_copyfrom_buffer, closes #3712885
dataimport.py
--- a/dataimport.py	Thu Apr 03 15:36:33 2014 +0200
+++ b/dataimport.py	Mon Apr 07 08:44:56 2014 +0000
@@ -472,11 +472,13 @@
                 if isinstance(value, unicode):
                     value = value.encode(encoding)
             elif isinstance(value, (date, datetime)):
-                # Do not use strftime, as it yields issue
-                # with date < 1900
                 value = '%04d-%02d-%02d' % (value.year,
                                             value.month,
                                             value.day)
+                if isinstance(value, datetime):
+                    value += ' %02d:%02d:%02d' % (value.hour,
+                                                  value.minutes,
+                                                  value.second)
             else:
                 return None
             # We push the value to the new formatted row