showed that the various Date operations were a big slowdown
Posted via http://www.ruby-forum.com/.
Simply put, Time values are stored as a long integer and all math on
them is done by adding or subtracting two values. This is very fast.
Date does a bunch of processing to make sure things work fine, which is
irb>require ‘ruby-units’ (gem for unit conversions and unit math)
irb>require ‘chronic’ (interprets natural language time specs)
irb>‘2 weeks’.from ‘today’
#=> Mon Nov 06 17:00:00 EST 2006
irb>‘2 weeks’.from ‘today’.to_date
also does… ‘ago’, ‘from’, ‘until’, etc…
but ruby-units doesn’t do months since they aren’t a fixed size
It does contain a number of helpers for converting back and forth
between time and date objects, and it will automatically convert to a
date object if any math you do takes you outside the normal range for a
for more about ruby-units see