From 65ed8a657e6ddc49e0a1ba13b99efd92eae320e1 Mon Sep 17 00:00:00 2001 From: Adam Meehan Date: Tue, 13 Jan 2009 20:05:55 +1100 Subject: [PATCH 1/2] format months names now respect i18n --- lib/validates_timeliness/formats.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/validates_timeliness/formats.rb b/lib/validates_timeliness/formats.rb index e419fd9..ba242b7 100644 --- a/lib/validates_timeliness/formats.rb +++ b/lib/validates_timeliness/formats.rb @@ -1,3 +1,5 @@ +require 'date' + module ValidatesTimeliness # A date and time format regular expression generator. Allows you to @@ -297,9 +299,17 @@ module ValidatesTimeliness 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 From 7ed76b51611c536ea9dca0740fed3cece5317cc0 Mon Sep 17 00:00:00 2001 From: Adam Meehan Date: Tue, 13 Jan 2009 20:07:24 +1100 Subject: [PATCH 2/2] removed i18n of month names from TODO --- TODO | 1 - 1 file changed, 1 deletion(-) diff --git a/TODO b/TODO index dbf9c89..c85ebe7 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ - :format option - :with_date and :with_time options - valid formats could come from locale file -- formats to use month and day names from i18n - add replace_formats instead add_formats :before