-
Notifications
You must be signed in to change notification settings - Fork 615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
to_hash method timezone offset #110
Comments
savon respects xs:datetime strings with timezones like: if your service does not send a timezone, then that means it's utc. protip: if you're using rails, take a look at: in_time_zone. |
Thanks, I tried |
just tried it again and to me it looks like it works perfectly fine:
my config is set to:
|
Sorry, don't think I was clear. The problem with
My config is set to:
Notice, that the time remains 11:22:33 in both cases. Hope this clarified what I was after. Thanks! |
did you see that it remains 12:22:33 in my example? really can't see a difference. |
Somehow, we're not seeing the same thing. Looking at your example again, and I see you have |
you're totally right. i'm sorry! but talking about savon ... if a service returns a datetime without a timezone, it's utc. that's just a standard. and if the datetime is actually meant to have a timezone but doesn't, it seems to me that either the service should change to return the right value or your app needs to know and deal with this. guess i need some more opinions on this. |
no opinions. closing the issue. sorry. |
Assuming that a datetime without a timezone is UTC is incorrect. According to ISO8601:
I am experiencing the same issue. The web service is not specifying timezone information, and savon is assuming that it's UTC, when it should be the local time zone. Could you please re-open the issue. Thanks! |
I did a little digging and it turns out the Time.parse() and DateTime.parse() behave differently. Time.parse() will properly set the offset to the local offset if none is specified, while DateTime.parse() will assume it's UTC if no offset is specified. Weird. Seems that rails uses Time.parse() over DateTime.parse(), but not sure if this is why. |
interesting. unfortunately, i don't have time to look into this right now and i'd really appreciate if you could help me out. |
also, this sounds like a change that could cause trouble for quite a few users. i'm all for changes to improve |
It seems like it's actually the Nori library doing the parsing. Is that accurate? |
I answered my own question. It is in fact parsed in the Nori library. The typecasting is done in the xml_utility_node class. Close this issue, I'll open one on Nori. Issue moved to rubiii/nori#22 |
I have a datetime string within an XML response:
2010-11-10T13:20:00
Calling Savon's to_hash method converts the string to a DateTime object:
Wed, 10 Nov 2010 13:20:00 +0000
This is great if the original datetime was in UTC. However, in my case, the original datetime is actually already in the local timezone which is Pacific Time (US & Canada). So after calling to_hash, the correct time should be:
Wed, 10 Nov 2010 13:20:00 +0800
The offset, would of course, be different if the original datetime was in daylight savings period.
How do I get the to_hash method to treat the original datetime as being in the local timezone, instead of UTC?
Much help would be appreciated, thanks!
The text was updated successfully, but these errors were encountered: