Last active
December 20, 2015 19:49
-
-
Save jsl/6186375 to your computer and use it in GitHub Desktop.
Rails date subtraction different on Mac OS and Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Using ruby-2.0.0-p247, Rails console | |
# On Mac: | |
2.0.0p247 :006 > Date.today - Date.yesterday | |
=> 1 | |
2.0.0p247 :007 > (Date.today - Date.yesterday).class | |
=> Fixnum | |
# On Ubuntu 12.04 | |
2.0.0p247 :009 > Date.today - Date.yesterday | |
=> (1/1) | |
2.0.0p247 :010 > (Date.today - Date.yesterday).class | |
=> Rational | |
# When I try to unload ActiveSupport extensions, I still see different behavior for Date: | |
# Mac OS X: | |
2.0.0-p247 :001 > Date.ancestors | |
=> [Date, Comparable, Object, Kernel, BasicObject] | |
# Linux | |
2.0.0p247 :002 > Date.ancestors | |
=> [Date, Object, Kernel, BasicObject] | |
# Something is still monkey-patching my Date? The initializers are also different - on OS X it takes three params (Y, M, D) and on Linux I get: | |
2.0.0p247 :006 > ::Date.new(2011, 01, 03) | |
ArgumentError: wrong number of arguments (3 for 0) | |
# OS X: | |
2.0.0-p247 :005 > Date.new(2001, 1, 1) | |
=> #<Date: 2001-01-01 ((2451911j,0s,0n),+0s,2299161j)> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment