Skip to content

Instantly share code, notes, and snippets.

@dball
Created April 21, 2012 04:58
Show Gist options
  • Save dball/2434109 to your computer and use it in GitHub Desktop.
Save dball/2434109 to your computer and use it in GitHub Desktop.
Time Zone Madness

BROKEN

(rdb:1) value.getutc.iso8601(3)
ArgumentError Exception: wrong number of arguments (1 for 0)
(rdb:1) value
Sun, 18 Nov 2007 03:56:07 EST -05:00
(rdb:1) value.class.ancestors
[ActiveSupport::TimeWithZone, Comparable, Object, Metaclass::ObjectMethods, Mocha::ObjectMethods, PP::ObjectMixin, MiniTest::Expectations, FactoryGirl::Syntax::Vintage, Rake::DeprecatedObjectDSL, JSON::Ext::Generator::GeneratorMethods::Object, ActiveSupport::Dependencies::Loadable, Base64::Deprecated, Base64, Kernel]
(rdb:1) value.class
ActiveSupport::TimeWithZone
[52, 61] in /Users/dball/.rvm/gems/ruby-1.8.7-p358/gems/activesupport-3.2.3/lib/active_support/time_with_zone.rb
   52        @time ||= period.to_local(@utc)
   53      end
   54  
   55      # Returns a Time or DateTime instance that represents the time in UTC.
   56      def utc
=> 57        @utc ||= period.to_utc(@time)
   58      end
   59      alias_method :comparable_time, :utc
   60      alias_method :getgm, :utc
   61      alias_method :getutc, :utc
/Users/dball/.rvm/gems/ruby-1.8.7-p358/gems/activesupport-3.2.3/lib/active_support/time_with_zone.rb:57
@utc ||= period.to_utc(@time)
(rdb:1) @utc
Sun, 18 Nov 2007 08:56:07 +0000
(rdb:1) @utc.class
DateTime

WORKING

(rdb:1) value.getutc.iso8601(3)
"2001-02-03T09:05:06.000Z"
(rdb:1) value
Sat, 03 Feb 2001 04:05:06 EST -05:00
(rdb:1) value.class.ancestors
[ActiveSupport::TimeWithZone, Comparable, Object, PP::ObjectMixin, JSON::Ext::Generator::GeneratorMethods::Object, Base64::Deprecated, Base64, ActiveSupport::Dependencies::Loadable, Mocha::ObjectMethods, Rake::DeprecatedObjectDSL, Kernel]
(rdb:1) value.class
ActiveSupport::TimeWithZone
[52, 61] in /Users/dball/.rvm/gems/ruby-1.8.7-p358/bundler/gems/rails-d5f2bae786cb/activesupport/lib/active_support/time_with_zone.rb
   52        @time ||= period.to_local(@utc)
   53      end
   54  
   55      # Returns a Time or DateTime instance that represents the time in UTC.
   56      def utc
=> 57        @utc ||= period.to_utc(@time)
   58      end
   59      alias_method :comparable_time, :utc
   60      alias_method :getgm, :utc
   61      alias_method :getutc, :utc
(rdb:1) @utc
Sat Feb 03 09:05:06 UTC 2001
(rdb:1) @utc.class
Time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment