diff options
author | gbuesing <gbuesing@gmail.com> | 2008-05-08 22:07:21 -0500 |
---|---|---|
committer | gbuesing <gbuesing@gmail.com> | 2008-05-08 22:07:21 -0500 |
commit | 4f03190f262c07c1f389957ff7ae76901495d824 (patch) | |
tree | 621f5ccd85e2815f46f95bbb4b2195c879680bba /activesupport/lib/active_support | |
parent | 618d695f1115c00ce058950af199d5d4dc06385a (diff) | |
download | rails-4f03190f262c07c1f389957ff7ae76901495d824.tar.gz rails-4f03190f262c07c1f389957ff7ae76901495d824.tar.bz2 rails-4f03190f262c07c1f389957ff7ae76901495d824.zip |
TimeWithZone: date part getter methods (#year #mon #day etc) are defined on class; no longer relying on method_missing
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/time_with_zone.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index 461d52e40e..21ddcaad48 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -163,6 +163,14 @@ module ActiveSupport utc.advance(options).in_time_zone(time_zone) end + %w(year mon month day mday hour min sec).each do |method_name| + class_eval <<-EOV + def #{method_name} + time.#{method_name} + end + EOV + end + def usec time.respond_to?(:usec) ? time.usec : 0 end |