Code
timestr = "2008-02-25T12:33:21-08:00"
timeval = Time.xmlschema(timestr)
print "This is the input string:\n"
print timestr
print "\nThis is what happens after we parse it:\n"
print timeval.xmlschema();
print "\nThis is what happens after we convert it to local:\n"
timeval.localtime
print timeval.xmlschema();
print "\n";`
Results
This is the input string:
2008-02-25T12:33:21-08:00
This is what happens after we parse it:
2008-02-25T20:33:21Z
This is what happens after we convert it to local:
2008-02-25T12:33:21-08:00
Explanation
This threw me for a loop earlier. See, I thought there was a really screwy bug in the Time.xmlschema implementation that was causing it to toss out the timezones. However, it turns out that it wasn’t tossing it out… it was just converting all timezones to GMT.
The problem is, you shouldn’t naively do that. That’s bad. If I’d wanted the timezone in GMT, I’d have converted it myself!