From bb6b14b04f9d3f1e8d8811588902eb7d61fb054e Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 24 Jun 2005 20:42:16 +0000 Subject: Increased accuracy of 1.year by accounting for leap years. The time extensions are not meant to be super-precise but this seems worth it since otherwise you lose a lot of days doing 40.years.ago. Closes #1488 [tuxie@dekadance.se] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1499 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/core_ext/numeric/time.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/core_ext/numeric') diff --git a/activesupport/lib/active_support/core_ext/numeric/time.rb b/activesupport/lib/active_support/core_ext/numeric/time.rb index 43c0425b00..de726281b8 100644 --- a/activesupport/lib/active_support/core_ext/numeric/time.rb +++ b/activesupport/lib/active_support/core_ext/numeric/time.rb @@ -32,9 +32,9 @@ module ActiveSupport #:nodoc: self * 30.days end alias :month :months - + def years - self * 365.days + (self * 365.25.days).to_i end alias :year :years -- cgit v1.2.3