From e4645e00b7a427f32e470b4ad3fe494b698f725d Mon Sep 17 00:00:00 2001 From: Geoff Buesing Date: Fri, 28 Mar 2008 01:57:41 +0000 Subject: TimeWithZone#usec returns 0 instead of error when DateTime is wrapped git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9105 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/time_with_zone.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/time_with_zone.rb') diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index 56c4f40f32..3c37ab2d4c 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -143,7 +143,7 @@ module ActiveSupport end end - %w(asctime day hour min mon sec usec wday yday year to_date).each do |name| + %w(asctime day hour min mon sec wday yday year to_date).each do |name| define_method(name) do time.__send__(name) end @@ -152,6 +152,10 @@ module ActiveSupport alias_method :mday, :day alias_method :month, :mon + def usec + time.respond_to?(:usec) ? time.usec : 0 + end + %w(sunday? monday? tuesday? wednesday? thursday? friday? saturday?).each do |name| define_method(name) do time.__send__(name) -- cgit v1.2.3