提交 bb6b14b0 编写于 作者: J Jeremy Kemper

Increased accuracy of 1.year by accounting for leap years. The time...

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
上级 c8e2cf3e
*SVN*
* Made 1.year == 365.25.days to account for leap years. This allows you to do User.find(:all, :conditions => ['birthday > ?', 50.years.ago]) without losing a lot of days. #1488 [tuxie@dekadance.se]
* Added an exception if calling id on nil to WhinyNil #584 [kevin-temp@writesoon.com]
* Added Fix/Bignum#multiple_of? which returns true on 14.multiple_of?(7) and false on 16.multiple_of?(7) #1464 [Thomas Fuchs]
......
......@@ -32,9 +32,9 @@ def months
self * 30.days
end
alias :month :months
def years
self * 365.days
(self * 365.25.days).to_i
end
alias :year :years
......
......@@ -9,7 +9,7 @@ def setup
10.minutes => 600,
1.hour + 15.minutes => 4500,
2.days + 4.hours + 30.minutes => 189000,
5.years + 1.month + 1.fortnight => 161481600
5.years + 1.month + 1.fortnight => 161589600
}
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册