Time zone varies when ruby version varies why?
-
15-02-2021 - |
Question
I am running Rails 3.0.1 with Ruby 1.9.2p290.In rails c
Time.zone
gives
=> (GMT+00:00) UTC
In my friends rails console [Rails 3.0.1, Ruby 1.8.7]
Time.zone
gives
#<ActiveSupport::TimeZone:0xb75834fc @tzinfo=#<TZInfo::TimezoneProxy: Etc/UTC>, @utc_offset=nil, @current_period=nil, @name="UTC">
Why different result for same code?
Solution
It just looks like the Ruby 1.9.2 class has a better inspect
method. Have you tried comparing what classes are involved?
Time.zone
# => (GMT+00:00) UTC
Time.zone.class
# => ActiveSupport::TimeZone
The class is just a wrapper around the core Ruby class, so if 1.9.2 has a better TimeZone object then it will appear differently.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow