我有一个DateTime类的对象属性.
如果保存的日期是今天,明天还是其他日期,我将如何理解?
解决方法
这里有一些有用的方法来实现它:
datetime = DateTime.now => Sun,26 Oct 2014 21:00:00 datetime.today? # => true datetime.to_date.past? # => false (only based on date) datetime.to_date.future? # => false (only based on date) datetime.to_date == Date.tomorrow # => false datetime.to_date == Date.yesterday # => false