Skip to content

Instantly share code, notes, and snippets.

@KELiON
Created August 13, 2014 09:56
Show Gist options
  • Save KELiON/6a4e8bb5ca06d1097153 to your computer and use it in GitHub Desktop.
Save KELiON/6a4e8bb5ca06d1097153 to your computer and use it in GitHub Desktop.
Default date parsing with locale
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