mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 07:16:41 +00:00
added switching to euro date formats instead of US
This commit is contained in:
19
README
19
README
@@ -129,6 +129,8 @@ you want. No regular expressions or duck punching (monkey patching) the plugin.
|
||||
d.m.yy
|
||||
d mmm yy
|
||||
|
||||
NOTE: to switch to using non-US date formats see US/EURO FORMATS section
|
||||
|
||||
Datetime formats:
|
||||
m/d/yy h:nn:ss OR d/m/yy hh:nn:ss
|
||||
m/d/yy h:nn OR d/m/yy h:nn
|
||||
@@ -138,6 +140,8 @@ you want. No regular expressions or duck punching (monkey patching) the plugin.
|
||||
ddd mmm d hh:nn:ss zo yyyy # Ruby time string
|
||||
yyyy-mm-ddThh:nn:ss(?:Z|zo) # ISO 8601
|
||||
|
||||
NOTE: to switch to using non-US date formats see US/EURO FORMATS section
|
||||
|
||||
Here is what each format token means:
|
||||
|
||||
Format tokens:
|
||||
@@ -177,6 +181,21 @@ regular expressions directly. So, no, it won't make your app slow!
|
||||
|
||||
To see all defined formats look in the lib/validates_timeliness/formats.rb.
|
||||
|
||||
=== US/EURO FORMATS
|
||||
|
||||
The perenial problem for non-US develops or applications not primarily for the
|
||||
US, is the US date format of m/d/yy. This is ambiguous with the European format
|
||||
of d/my/yy. By default the plugin uses the US formats as this is the Ruby default
|
||||
when it does date interpretation, and is in keeping PoLS (principle of least
|
||||
surprise).
|
||||
|
||||
To switch to using the European (or Rest of The World) formats put this in an
|
||||
initializer or environment.rb
|
||||
|
||||
ValidatesTimeliness::Formats.remove_us_formats
|
||||
|
||||
Now '01/02/2000' will be parsed as 1st February 2000, instead of 2nd January 2000.
|
||||
|
||||
=== CUSTOMISING FORMATS:
|
||||
|
||||
I hear you say "Thats greats but I don't want X format to be valid". Well to
|
||||
|
||||
Reference in New Issue
Block a user