I have the following JSON:
{"dtime" : "2020-08-26T15:30:00+03:00"}
Parsing it, yields the following date:
=> 2020-08-26 14:30:00 +0200
Why does it have a +2 offset and not a +3 one?
EDIT: I'm using Rails 3.2.13, with ActiveSupport 3.2.13. I'm trying to parse the string by using:
Time.parse(string)
I've noticed, however, that if I parse it with:
DateTime.parse(string)
I get a correct offset.
I have no business answering this question, because I don't use Ruby. That said, just looking at the standard library, it seems the reason is
Time.parse
includes a call tolocaltime
, which converts the parse result into your local time zone.I suspect you're actually executing this code in GMT +02. You can check with
Time.new
. I'm running in GMT -07.You can convert the result into any time zone by passing it to
localtime
.