Side navigation
#2682 closed enhancement (wontfix)
Opened April 11, 2008 10:12PM UTC
Closed June 10, 2009 09:09AM UTC
[validate] Better ISO date and time validation
| Reported by: | DThrasher | Owned by: | joern |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.2.4 |
| Component: | plugin | Version: | 1.2.3 |
| Keywords: | validate | Cc: | |
| Blocked by: | Blocking: |
Description
I have a few suggestions for enhancing the ISO date and time RegEx expressions. I modified a few examples I found on http://regexlib.com. The current dateISO validator allows nonsensical dates like 2008-67-87.
ISO date
^(\\d{4})\\D?(0[1-9]|1[0-2])\\D?([12]\\d|0[1-9]|3[01])$
ISO time
^([01]\\d|2[0-3])\\D?([0-5]\\d)\\D?([0-5]\\d)?\\D?(\\d{3})?$
ISO offset
^([zZ]|([\\+-])([01]\\d|2[0-3])\\D?([0-5]\\d)?)?$
ISO date and time
^(\\d{4})\\D?(0[1-9]|1[0-2])\\D?([12]\\d|0[1-9]|3[01])(\\D?([01]\\d|2[0-3])\\D?([0-5]\\d)\\D?([0-5]\\d)?\\D?(\\d{3})?)?$
ISO Date, time and offset (the works)
^(\\d{4})\\D?(0[1-9]|1[0-2])\\D?([12]\\d|0[1-9]|3[01])(\\D?([01]\\d|2[0-3])\\D?([0-5]\\d)\\D?([0-5]\\d)?\\D?(\\d{3})?([zZ]|([\\+-])([01]\\d|2[0-3])\\D?([0-5]\\d)?)?)?$
Attachments (0)
Change History (3)
Changed May 25, 2008 11:37AM UTC by comment:1
| description: | I have a few suggestions for enhancing the ISO date and time RegEx expressions. I modified a few examples I found on http://regexlib.com. The current dateISO validator allows nonsensical dates like 2008-67-87. \ \ ISO date \ ^(\\d{4})\\D?(0[1-9]|1[0-2])\\D?([12]\\d|0[1-9]|3[01])$ \ \ ISO time \ ^([01]\\d|2[0-3])\\D?([0-5]\\d)\\D?([0-5]\\d)?\\D?(\\d{3})?$ \ \ ISO offset \ ^([zZ]|([\\+-])([01]\\d|2[0-3])\\D?([0-5]\\d)?)?$ \ \ ISO date and time \ ^(\\d{4})\\D?(0[1-9]|1[0-2])\\D?([12]\\d|0[1-9]|3[01])(\\D?([01]\\d|2[0-3])\\D?([0-5]\\d)\\D?([0-5]\\d)?\\D?(\\d{3})?)?$ \ \ ISO Date, time and offset (the works) \ ^(\\d{4})\\D?(0[1-9]|1[0-2])\\D?([12]\\d|0[1-9]|3[01])(\\D?([01]\\d|2[0-3])\\D?([0-5]\\d)\\D?([0-5]\\d)?\\D?(\\d{3})?([zZ]|([\\+-])([01]\\d|2[0-3])\\D?([0-5]\\d)?)?)?$ → I have a few suggestions for enhancing the ISO date and time RegEx expressions. I modified a few examples I found on http://regexlib.com. The current dateISO validator allows nonsensical dates like 2008-67-87. \ \ {{{ \ ISO date \ ^(\\d{4})\\D?(0[1-9]|1[0-2])\\D?([12]\\d|0[1-9]|3[01])$ \ \ ISO time \ ^([01]\\d|2[0-3])\\D?([0-5]\\d)\\D?([0-5]\\d)?\\D?(\\d{3})?$ \ \ ISO offset \ ^([zZ]|([\\+-])([01]\\d|2[0-3])\\D?([0-5]\\d)?)?$ \ \ ISO date and time \ ^(\\d{4})\\D?(0[1-9]|1[0-2])\\D?([12]\\d|0[1-9]|3[01])(\\D?([01]\\d|2[0-3])\\D?([0-5]\\d)\\D?([0-5]\\d)?\\D?(\\d{3})?)?$ \ \ ISO Date, time and offset (the works) \ ^(\\d{4})\\D?(0[1-9]|1[0-2])\\D?([12]\\d|0[1-9]|3[01])(\\D?([01]\\d|2[0-3])\\D?([0-5]\\d)\\D?([0-5]\\d)?\\D?(\\d{3})?([zZ]|([\\+-])([01]\\d|2[0-3])\\D?([0-5]\\d)?)?)?$ \ }}} |
|---|
Changed May 25, 2008 11:38AM UTC by comment:2
| owner: | → joern |
|---|
Changed June 10, 2009 09:09AM UTC by comment:3
| resolution: | → wontfix |
|---|---|
| status: | new → closed |
Providing a "complete" date method isn't feasible, therefore you have to write your own custom method for specific date formats.