Hello, I am trying to convert a local time into UTC ISO8601, then parse it back into local time. I tried the following:
---------------------- #!/usr/bin/python import time import datetime import xml.utils.iso8601 year = 2005 month = 7 day = 22 hour = 10 # This is localtime minute = 30 mydatetime = datetime.datetime(year, month, day, hour, minute) strtime = mydatetime.isoformat() print "Time: " + strtime # Localtime too mytimestamp = xml.utils.iso8601.parse(strtime) ---------------------- How can I convert this into UTC? Commonsense would have me guess that the date is converted into UTC on construction of the datetime object, hovever, this doesn't seem to be the case. I also found the astimezone(tz) method, but where can I obtain the concrete tz object? The second problem has to do with the ISO8601 parser, which raises the following error: ---------------------- Traceback (most recent call last): File "./timetest.py", line 16, in ? mytimestamp = xml.utils.iso8601.parse(strtime) File "/usr/lib/python2.4/site-packages/_xmlplus/utils/iso8601.py", line 22, in parse raise ValueError, "unknown or illegal ISO-8601 date format: " + `s` ValueError: unknown or illegal ISO-8601 date format: '2005-07-22T10:30:00' ---------------------- Why does it fail to parse the value returned by the datetime object, and how can I create a parseable time from the datetime object? Thanks, -Samuel -- http://mail.python.org/mailman/listinfo/python-list