Rails dates and times, 40.years.ago

Simple test case:
require 'rubygems'
require 'active_support'
puts 5.years.ago
puts 40.years.ago

It seems to be an issue on windows, as the linux version of the test
below works just fine, but windows will crash with an ArgumentError:
time must be positive.

Does anyone have a solution/workaround so that I can create database
queries that search for users older than 35 on my windows test box?

Thank you.

jgeiger@gmail.com wrote:

Simple test case:
require 'rubygems'
require 'active_support'
puts 5.years.ago
puts 40.years.ago

It seems to be an issue on windows, as the linux version of the test
below works just fine, but windows will crash with an ArgumentError:
time must be positive.

Does anyone have a solution/workaround so that I can create database
queries that search for users older than 35 on my windows test box?

Thank you.

The 'ruby-units' gem can handle datetime math like this and will
automagically convert to a DateTime from a Time when necessary.

Using ruby-units, you would use

'40 years'.ago

_Kevin