lib/validates_timeliness/formats.rb in adzap-validates_timeliness-1.1.3 vs lib/validates_timeliness/formats.rb in adzap-validates_timeliness-1.1.4
- old
+ new
@@ -1,5 +1,7 @@
+require 'date'
+
module ValidatesTimeliness
# A date and time format regular expression generator. Allows you to
# construct a date, time or datetime format using predefined tokens in
# a string. This makes it much easier to catalogue and customize the formats
@@ -295,12 +297,20 @@
year.to_i
end
def month_index(month)
return month.to_i if month.to_i.nonzero?
- Date::ABBR_MONTHNAMES.index(month.capitalize) || Date::MONTHNAMES.index(month.capitalize)
+ abbr_month_names.index(month.capitalize) || month_names.index(month.capitalize)
end
-
+
+ def month_names
+ defined?(I18n) ? I18n.t('date.month_names') : Date::MONTHNAMES
+ end
+
+ def abbr_month_names
+ defined?(I18n) ? I18n.t('date.abbr_month_names') : Date::ABBR_MONTHNAMES
+ end
+
def microseconds(usec)
(".#{usec}".to_f * 1_000_000).to_i
end
end
end