Brian Donovan 写了一篇 非常不错的文章 Time convience methods 所做的 Duration 修正。
1 2 3 4 |
Time.now #=> Thu Jan 25 21:01:31 -0800 2007 1.month.from_now #=> Sat Feb 24 21:01:34 -0800 2007 |
我们发现month.from_now只在原日期上增加了30天,造成了在1月25号的一个月后是2月24号的错误。
在Edge里已经得到修复:
1 2 3 4 |
Time.now #=> Thu Jan 25 21:01:31 -0800 2007 1.month.from_now #=> Sun Feb 25 21:01:34 -0800 2007 |
再让我们来看看 inspect 的好东西:
1 2 |
>> 3.weeks #=> 21 days |
到最后您便能发现这个文章标题的意义了,这个修正对所有的 time helpers 都会生效,而不仅仅针对 month.from_now。 最后,我们可以通过阅读 整篇原文 来汲取更多相关信息。
原文作者是 Ryan Daigle, 请访问他的博客
本篇译文的原文地址:http://ryandaigle.com/articles/2007/1/26/what-s-new-in-edge-rails-1-month-from_now-no_longer-effed



