mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-22 22:06:45 +00:00
allow uppercase meridian to be valid
This commit is contained in:
parent
604a792e25
commit
889bdc3ae3
@ -1,3 +1,6 @@
|
||||
[2008-11-13]
|
||||
- allow uppercase meridian to be valid
|
||||
|
||||
[2008-10-28]
|
||||
- fixed bug when dirty attributes not reflecting change when attribute changed from time value to nil [reported by Brad (pvjq)]
|
||||
- fixes for Rails 2.2 compatibility. Will refactor in to Rails version specific branches in the future.
|
||||
|
||||
@ -123,7 +123,7 @@ module ValidatesTimeliness
|
||||
{ 'ss' => [ /s{2,}/, '(\d{2})', :sec ] },
|
||||
{ 's' => [ /s{1}/, '(\d{1,2})', :sec ] },
|
||||
{ 'u' => [ /u{1,}/, '(\d{1,6})', :usec ] },
|
||||
{ 'ampm' => [ /ampm/, '((?:a|p)\.?m\.?)', :meridian ] },
|
||||
{ 'ampm' => [ /ampm/, '((?:[aApP])\.?[mM]\.?)', :meridian ] },
|
||||
{ 'zo' => [ /zo/, '(?:[+-]\d{2}:?\d{2})'] },
|
||||
{ 'tz' => [ /tz/, '(?:[A-Z]{1,4})' ] },
|
||||
{ '_' => [ /_/, '\s?' ] }
|
||||
|
||||
@ -13,11 +13,11 @@ describe ValidatesTimeliness::Formats do
|
||||
end
|
||||
|
||||
it "should generate regexp for time with meridian" do
|
||||
generate_regexp_str('hh:nn:ss ampm').should == '/(\d{2}):(\d{2}):(\d{2}) ((?:a|p)\.?m\.?)/'
|
||||
generate_regexp_str('hh:nn:ss ampm').should == '/(\d{2}):(\d{2}):(\d{2}) ((?:[aApP])\.?[mM]\.?)/'
|
||||
end
|
||||
|
||||
it "should generate regexp for time with meridian and optional space between" do
|
||||
generate_regexp_str('hh:nn:ss_ampm').should == '/(\d{2}):(\d{2}):(\d{2})\s?((?:a|p)\.?m\.?)/'
|
||||
generate_regexp_str('hh:nn:ss_ampm').should == '/(\d{2}):(\d{2}):(\d{2})\s?((?:[aApP])\.?[mM]\.?)/'
|
||||
end
|
||||
|
||||
it "should generate regexp for time with single or double digits" do
|
||||
@ -83,7 +83,7 @@ describe ValidatesTimeliness::Formats do
|
||||
'h.nn' => {:pass => ['2.12', '12.12'], :fail => ['2.1', '12:12']},
|
||||
'h nn' => {:pass => ['2 12', '12 12'], :fail => ['2 1', '2.12', '12:12']},
|
||||
'h-nn' => {:pass => ['2-12', '12-12'], :fail => ['2-1', '2.12', '12:12']},
|
||||
'h:nn_ampm' => {:pass => ['2:12am', '2:12 pm'], :fail => ['1:2am', '1:12 pm', '2.12am']},
|
||||
'h:nn_ampm' => {:pass => ['2:12am', '2:12 pm', '2:12 AM', '2:12PM'], :fail => ['1:2am', '1:12 pm', '2.12am']},
|
||||
'h.nn_ampm' => {:pass => ['2.12am', '2.12 pm'], :fail => ['1:2am', '1:12 pm', '2:12am']},
|
||||
'h nn_ampm' => {:pass => ['2 12am', '2 12 pm'], :fail => ['1 2am', '1 12 pm', '2:12am']},
|
||||
'h-nn_ampm' => {:pass => ['2-12am', '2-12 pm'], :fail => ['1-2am', '1-12 pm', '2:12am']},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user