Created
August 13, 2014 09:56
-
-
Save KELiON/6a4e8bb5ca06d1097153 to your computer and use it in GitHub Desktop.
Default date parsing with locale
This file contains 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
module ActiveRecord | |
module ConnectionAdapters | |
class Column | |
class << self | |
protected | |
def fallback_string_to_date(string) | |
format = I18n.t("date.formats.default") | |
date = begin | |
::Date._strptime(string, format) | |
rescue | |
::Date._parse(string, false) | |
end | |
new_date(*date.values_at(:year, :mon, :mday)) | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment