Tuesday, October 19, 2010

Re: Dates before 1600-01-01 are not recognized by models' date fields?

On Tue, Oct 19, 2010 at 6:02 AM, psybear83 <psybear83@gmail.com> wrote:
> Hi everybody
>
> Is there a reason why CakePHP doesn't recognize dates before
> 1600-01-01? I get a validation error when submitting a date before
> that (e.g. 1599-31-12 or 1300-11-05).

Use the source, Luke.
http://api.cakephp.org/view_source/validation/#line-389

--snip--
$regex['ymd'] =
'%^(?:(?:(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\\/|-|\\.|\\x20)(?:0?2\\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\\d)?\\d{2})(\\/|-|\\.|\\x20)(?:(?:(?:0?[13578]|1[02])\\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\\2(?:0?[1-9]|1\\d|2[0-8]))))$%';
--snip--

Note the "1[6-9]|[2-9]". I believe that's saying, "(1 AND 6-9) OR (1
AND 2-9), which wouldn't be desirable. Although, if it's supposed to
be, "1 AND (6-9 OR 2-9) it still doesn't make much sense.

Or maybe it's the "16|[2468][048]|[3579][26])00" part. I'm going
cross-eyed looking at this.

I figured the trouble would be due to something like this. For routes,
one can use the built-in $Year, which is a regexp defined as
"[12][0-9]{3}". So, nothing before year 1000, in that case. I think it
should be "[12]?[0-9]{3}". But, then that would limit you only to
dates after 100AD, of course.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate