mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-23 06:16:44 +00:00
Merge branch 'months'
This commit is contained in:
commit
575ff85346
1
TODO
1
TODO
@ -1,5 +1,4 @@
|
|||||||
- :format option
|
- :format option
|
||||||
- :with_date and :with_time options
|
- :with_date and :with_time options
|
||||||
- valid formats could come from locale file
|
- valid formats could come from locale file
|
||||||
- formats to use month and day names from i18n
|
|
||||||
- add replace_formats instead add_formats :before
|
- add replace_formats instead add_formats :before
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
require 'date'
|
||||||
|
|
||||||
module ValidatesTimeliness
|
module ValidatesTimeliness
|
||||||
|
|
||||||
# A date and time format regular expression generator. Allows you to
|
# A date and time format regular expression generator. Allows you to
|
||||||
@ -297,9 +299,17 @@ module ValidatesTimeliness
|
|||||||
|
|
||||||
def month_index(month)
|
def month_index(month)
|
||||||
return month.to_i if month.to_i.nonzero?
|
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
|
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)
|
def microseconds(usec)
|
||||||
(".#{usec}".to_f * 1_000_000).to_i
|
(".#{usec}".to_f * 1_000_000).to_i
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user