1

Ruby 1.9.2p290でRails 3.0.1を実行しています.In rails c

Time.zone

与える

 => (GMT+00:00) UTC

友達の Rails コンソール [Rails 3.0.1、Ruby 1.8.7]

Time.zone

与える

#<ActiveSupport::TimeZone:0xb75834fc @tzinfo=#<TZInfo::TimezoneProxy: Etc/UTC>, @utc_offset=nil, @current_period=nil, @name="UTC">

同じコードで結果が異なるのはなぜですか?

4

1 に答える 1

3

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.

于 2011-10-28T15:40:34.813 に答える