Incorrect Dates/Timestamps
tisba opened this issue · 5 comments
I noticed that this gem reports a response with datesubmitted
as Wed, 15 Apr 2015 05:46:30 +0000
which is not correct, since according to SurveyGizmo are all timestamps in EST (which is UTC -05:00).
It turns out, SurveyGizmo does not send a timezone at all with date/time attributes :-(. The raw response for datesubmitted
is "2015-04-15 05:46:30"
and has to be interpreted as EST (-0500). A nasty "hack" could be to parse this via Time.parse(value << " EST")
.
So the correct time in my case would be Wed, 15 Apr 2015 10:46:30 +0000
(or Wed, 15 Apr 2015 05:46:30 +0500
). IMO this is pretty messed up by SG, but the misinterpretation of this gem makes it even worse.
The following monkey patched lead to the correct result. I'll try to make this into a PR when I find some time.
module SurveyGizmo
module API
class Response
def datesubmitted=(new_date)
super new_date << " EST"
end
end
end
end
Thanks @tisba, that's a good catch :)
Another crap from the SurveyGizmo API...
A pull request would be greatly appreciated 👍
Hey @jarthod, could you give the PR a look? It was a bit nasty to extend the specs, but I think I've found an acceptable solution. I'd very much appreciate if you could cut a new version if possible.
I decided against the approach from my monkey patch, so that only the response from the SurveyGizmo API is changed. The previous approach would have appended EST
every time someone called SurveyGizmo::API::Response#datesubmitted=
which would lead to an unexpected behavior.
Thanks a lot, this is merged and released as 2.0.1
🍻
Awesome! 👍