Active Support Date and Time

Posted by root Sun, 10 Aug 2008 13:38:00 GMT

n = Time.now

(n.at_end_of_week - n.at_beginning_of_week) / (24 * 3600)

# 6.99998842592593

Shouldn’t it be 7 exactly?

Probably because the start of a week is 00:00:00 and the end is 23:59:59:
>> Time.now.at_beginning_of_week
=> Mon Aug 04 00:00:00 +0300 2008

>> Time.now.at_end_of_week
=> Sun Aug 10 23:59:59 +0300 2008

Posted in  | Tags  | no comments | no trackbacks

Comments

Trackbacks

Use the following link to trackback from your own site:
http://www.vidul.com/articles/trackback/78

Comments are disabled