mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-22 22:06:45 +00:00
dusting
This commit is contained in:
parent
896427a8d5
commit
c804442330
@ -10,15 +10,7 @@ module ValidatesTimeliness
|
|||||||
# string values.
|
# string values.
|
||||||
#
|
#
|
||||||
class Parser
|
class Parser
|
||||||
cattr_accessor :time_formats,
|
cattr_reader :time_expressions, :date_expressions, :datetime_expressions
|
||||||
:date_formats,
|
|
||||||
:datetime_formats,
|
|
||||||
:time_expressions,
|
|
||||||
:date_expressions,
|
|
||||||
:datetime_expressions,
|
|
||||||
:format_tokens,
|
|
||||||
:format_proc_args
|
|
||||||
|
|
||||||
|
|
||||||
# Set the threshold value for a two digit year to be considered last century
|
# Set the threshold value for a two digit year to be considered last century
|
||||||
#
|
#
|
||||||
@ -73,6 +65,7 @@ module ValidatesTimeliness
|
|||||||
# by the next lowest length valid repeating token (e.g. yyy will be
|
# by the next lowest length valid repeating token (e.g. yyy will be
|
||||||
# replaced with yy)
|
# replaced with yy)
|
||||||
|
|
||||||
|
cattr_accessor :time_formats
|
||||||
@@time_formats = [
|
@@time_formats = [
|
||||||
'hh:nn:ss',
|
'hh:nn:ss',
|
||||||
'hh-nn-ss',
|
'hh-nn-ss',
|
||||||
@ -87,6 +80,7 @@ module ValidatesTimeliness
|
|||||||
'h_ampm'
|
'h_ampm'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
cattr_accessor :date_formats
|
||||||
@@date_formats = [
|
@@date_formats = [
|
||||||
'yyyy-mm-dd',
|
'yyyy-mm-dd',
|
||||||
'yyyy/mm/dd',
|
'yyyy/mm/dd',
|
||||||
@ -101,6 +95,7 @@ module ValidatesTimeliness
|
|||||||
'd mmm yy'
|
'd mmm yy'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
cattr_accessor :datetime_formats
|
||||||
@@datetime_formats = [
|
@@datetime_formats = [
|
||||||
'yyyy-mm-dd hh:nn:ss',
|
'yyyy-mm-dd hh:nn:ss',
|
||||||
'yyyy-mm-dd h:nn',
|
'yyyy-mm-dd h:nn',
|
||||||
@ -132,11 +127,11 @@ module ValidatesTimeliness
|
|||||||
# is required. The first capture group will be considered a literal and put
|
# is required. The first capture group will be considered a literal and put
|
||||||
# into the validation regexp string as-is. This is a hack.
|
# into the validation regexp string as-is. This is a hack.
|
||||||
#
|
#
|
||||||
|
cattr_accessor :format_tokens
|
||||||
@@format_tokens = {
|
@@format_tokens = {
|
||||||
'ddd' => [ '\w{3,9}' ],
|
'ddd' => [ '\w{3,9}' ],
|
||||||
'dd' => [ '\d{2}', :day ],
|
'dd' => [ '\d{2}', :day ],
|
||||||
'd' => [ '\d{1,2}', :day ],
|
'd' => [ '\d{1,2}', :day ],
|
||||||
'ampm' => [ '[aApP]\.?[mM]\.?', :meridian ],
|
|
||||||
'mmm' => [ '\w{3,9}', :month ],
|
'mmm' => [ '\w{3,9}', :month ],
|
||||||
'mm' => [ '\d{2}', :month ],
|
'mm' => [ '\d{2}', :month ],
|
||||||
'm' => [ '\d{1,2}', :month ],
|
'm' => [ '\d{1,2}', :month ],
|
||||||
@ -149,6 +144,7 @@ module ValidatesTimeliness
|
|||||||
'ss' => [ '\d{2}', :sec ],
|
'ss' => [ '\d{2}', :sec ],
|
||||||
's' => [ '\d{1,2}', :sec ],
|
's' => [ '\d{1,2}', :sec ],
|
||||||
'u' => [ '\d{1,6}', :usec ],
|
'u' => [ '\d{1,6}', :usec ],
|
||||||
|
'ampm' => [ '[aApP]\.?[mM]\.?', :meridian ],
|
||||||
'zo' => [ '[+-]\d{2}:?\d{2}', :offset ],
|
'zo' => [ '[+-]\d{2}:?\d{2}', :offset ],
|
||||||
'tz' => [ '[A-Z]{1,4}' ],
|
'tz' => [ '[A-Z]{1,4}' ],
|
||||||
'_' => [ '\s?' ]
|
'_' => [ '\s?' ]
|
||||||
@ -163,6 +159,7 @@ module ValidatesTimeliness
|
|||||||
# The code can be used to manipulate the arg value if required, otherwise
|
# The code can be used to manipulate the arg value if required, otherwise
|
||||||
# should just be the arg name.
|
# should just be the arg name.
|
||||||
#
|
#
|
||||||
|
cattr_accessor :format_proc_args
|
||||||
@@format_proc_args = {
|
@@format_proc_args = {
|
||||||
:year => [0, 'y', 'unambiguous_year(y)'],
|
:year => [0, 'y', 'unambiguous_year(y)'],
|
||||||
:month => [1, 'm', 'month_index(m)'],
|
:month => [1, 'm', 'month_index(m)'],
|
||||||
@ -175,7 +172,6 @@ module ValidatesTimeliness
|
|||||||
:meridian => [nil, 'md', nil]
|
:meridian => [nil, 'md', nil]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@type_wrapper = {
|
@@type_wrapper = {
|
||||||
:date => [/\A/, nil],
|
:date => [/\A/, nil],
|
||||||
:time => [nil , /\Z/],
|
:time => [nil , /\Z/],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user