Hi - I recently upgraded to the new 2.8a version, and ran into a minor
issue with the dateTime parsing code.

In particular, I'm receiving messages with times including fractional
seconds, i.e. "2013-01-29T00:53:58.545024". I'm no XML expert, but a
quick web search seems to indicate that this is a valid xsd:dateTime
instance - i.e. http://books.xmlschemata.org/relaxng/ch19-77049.html
includes in the valid example list "2001-10-26T21:32:52.12679".

This results in an exception:
  .... in gds_parse_datetime
    '%Y-%m-%dT%H:%M:%S').replace(tzinfo = tz)
  File "/usr/lib64/python2.6/_strptime.py", line 328, in _strptime
    data_string[found.end():])
ValueError: unconverted data remains: .545024

There may be a more elegant solution, but I tweaked my generated code by
modifying gds_parse_datetime() like:

-            return datetime.strptime(input_data,
-                '%Y-%m-%dT%H:%M:%S').replace(tzinfo = tz)
+            if len(input_data.split('.')) > 1:
+                dt = datetime.strptime(input_data, '%Y-%m-%dT%H:%M:%S.%f')
+            else:
+                dt = datetime.strptime(input_data, '%Y-%m-%dT%H:%M:%S')
+            return dt.replace(tzinfo = tz)

This seems to produce correct results with and without the fractional
second - though note per
http://stackoverflow.com/questions/698223/how-can-i-parse-a-time-string-containing-milliseconds-in-it-with-python
 the %f conversion type is new in python 2.6 - not a problem for me but I don't 
know how backwards compatible you want to be ...

Thanks for the time maintaining the tool!

--Matt


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to