Commit 44bc307f authored by Ivan Tyagov's avatar Ivan Tyagov

Convert explicitly DateTime values to UTC.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17867 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b1f0660c
...@@ -19,6 +19,7 @@ from Shared.DC.ZRDB import sqlvar ...@@ -19,6 +19,7 @@ from Shared.DC.ZRDB import sqlvar
from string import atoi,atof from string import atoi,atof
from types import StringType from types import StringType
from Products.ERP5Type.PsycoWrapper import psyco from Products.ERP5Type.PsycoWrapper import psyco
from DateTime import DateTime
def SQLVar_render(self, md): def SQLVar_render(self, md):
name=self.__name__ name=self.__name__
...@@ -70,17 +71,15 @@ def SQLVar_render(self, md): ...@@ -70,17 +71,15 @@ def SQLVar_render(self, md):
try: try:
if getattr(v, 'ISO', None) is not None: if getattr(v, 'ISO', None) is not None:
v=v.ISO() v=v.toZone('UTC').ISO()
elif getattr(v, 'strftime', None) is not None: else:
v=v.strftime('%Y-%m-%d %H:%M:%S') v = DateTime(v)
else: v=v.toZone('UTC').ISO()
v=str(v)
except: except:
if not v and args.has_key('optional') and args['optional']: if not v and args.has_key('optional') and args['optional']:
return 'null' return 'null'
raise ValueError, ( raise ValueError, (
'Invalid datetime value for <em>%s</em>: %r' % (name, v)) 'Invalid datetime value for <em>%s</em>: %r' % (name, v))
v=md.getitem('sql_quote__',0)(v) v=md.getitem('sql_quote__',0)(v)
# End of patch # End of patch
else: else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment