开发者

evaluating/comparing amount of time passed

开发者 https://www.devze.com 2023-03-25 11:25 出处:网络
The following code evaluates that the time being parsed is greate开发者_StackOverflow中文版r than 30 days ago.

The following code evaluates that the time being parsed is greate开发者_StackOverflow中文版r than 30 days ago.

Time.parse("2011-01-03T14:31:57Z") < 30.days.ago
 => true

Why is this true? It looks to me like the < is going the wrong way, and ought to be >. What am I missing?


30.days.ago is a time, that time being 30 days ago. You're seeing if your time is earlier than 30 days ago, and it is.

So, don't read it as "less than 30 days ago", read it as "before 30 days ago", or "earlier than 30 days ago".


> refers to being a date past or "greater than" the preceding date. 30 days ago is past January 3rd, therefor it is greater.

0

精彩评论

暂无评论...
验证码 换一张
取 消