we are currently working on a rails project that uses i18n and we have small problem with the dates:
# on my mac
"10.06.2008".to_date
# produces => Tue, 10 Jun 2008
# on a friends mac and on the production server
"10.06.2008".to_date
# produces => ..., 06 Oct 2008
As you can see the dates aren’t right. We checked everything. The locale.yml (de.yml) is fine on both systems and the default_locale is set, too. The only difference between our systems is the ruby version. I’m running ruby 1.8.7 and he is running 1.8.6. Can this be the reason for this behaviour?
Any help would be appreciated.
Yes, the Ruby version is the difference.
String#to_datecallsDate._parseinternally, and that returns different results for Ruby 1.8.6 and 1.8.7.1.8.7:
1.8.6:
The change log for 1.8.7 mentions a change to the way dates are being parsed:
Even though the four-digit version from your example is not explicitly mentioned, the same change probably causes the difference. The workaround would be to use
Date.strptime.