Ack, poor logic. I need to think before I speak. On Sep 14, 11:33 am, LunarDraco <[email protected]> wrote: > Date format is a very interesting problem. Mostly though only in the > US. > The order and format of a date can take on many forms. For some reason > in the US the common public form is Month Day, Year as in Sep 1, 2010 > abreviated 9/1/2010 where if you abbreviate with hyphens instead of > '/' as in 9-1-2010 this represents 9 Jan 2010. > > All most everywhere else on the planet the format is Day Month Year as > in 1 Sep 2010 or 1-9-2010 > Programatically in SQL we use year-month-day hour:min:second.micro. > 2010-09-01 12:00:00.123 > ISO 8601 2004-02-12T15:19:21+00:00 > As validation is for verifying data input we need to consider the > mindset of the community that will be using our software and provide > the proper conversions from that input to the format we need for our > Database etc. > Explore php parse_date() and see what it makes of all the different > formats. > > On top of all of this info it seems that September is the only month > that has two acceptable short or abbreviations (Sep, Sept) all the > other months only ever use 3 chars. > > If you adjust the regex to the following both short forms will > validate. Sep as well as Sept > This looks to be something that might be worth entering a defect for. > I'm not sure if the core team was trying to match the short form of a > given spec or some other standard. But most of my validations are for > the benefit of the user not some specified standard. Further more most > of my users are lazy and that extra 't' is just to much for some of > them to type ;) > If the short form Sep 1, 2010 is not truly valid say for the database > date format etc. Then you would want/need to add some beforeSave code > to clean up the format. I haven't look real deep into the cakephp code > in how the Date data is converted back and forth between the UI > display and the Database, but if its using the parse_date() function > both formats work correctly. > > $regex['Mdy'] = '/^(?:(((Jan(uary)?|Ma(r(ch)?|y)|Jul(y)?|Aug(ust)?| > Oct(ober)?|Dec(ember)?)\\ 31)|((Jan(uary)?|Ma(r(ch)?|y)|Apr(il)?| > Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|Sep(tember)?|(Sept|Nov|Dec) > (ember)?)\\ > (0?[1-9]|([12]\\d)|30))|(Feb(ruary)?\\ (0?[1-9]|1\\d|2[0-8]|(29(?=,?\\ > ((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]| > [3579][26])00)))))))\\,?\\ ((1[6-9]|[2-9]\\d)\\d{2}))$/'; > > On Sep 12, 2:19 pm, Imaginextra <[email protected]> wrote: > > > I came across the same problem ... The way I found to fix it was to > > change line 403 in cake>libs>model>validation.php (Cakephp 1.3.4) > > from > > > $regex['Mdy'] = '/^(?:(((Jan(uary)?|Ma(r(ch)?|y)|Jul(y)?|Aug(ust)?| > > Oct(ober)?|Dec(ember)?)\\ 31)|((Jan(uary)?|Ma(r(ch)?|y)|Apr(il)?| > > Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sept|Nov|Dec)(ember)?)\\ (0? > > [1-9]|([12]\\d)|30))|(Feb(ruary)?\\ (0?[1-9]|1\\d|2[0-8]|(29(?=,?\\ > > ((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]| > > [3579][26])00)))))))\\,?\\ ((1[6-9]|[2-9]\\d)\\d{2}))$/'; > > > to > > > $regex['Mdy'] = '/^(?:(((Jan(uary)?|Ma(r(ch)?|y)|Jul(y)?|Aug(ust)?| > > Oct(ober)?|Dec(ember)?)\\ 31)|((Jan(uary)?|Ma(r(ch)?|y)|Apr(il)?| > > Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|Sep(tember)?|(Nov|Dec)(ember)?)\\ > > (0?[1-9]|([12]\\d)|30))|(Feb(ruary)?\\ (0?[1-9]|1\\d|2[0-8]|(29(?=,?\\ > > ((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]| > > [3579][26])00)))))))\\,?\\ ((1[6-9]|[2-9]\\d)\\d{2}))$/'; > > > not recommended to mess with the core but it works. > > > On Aug 4, 5:03 pm, Brenda <[email protected]> wrote: > > > > I have event_date in my model, with this validation rule: > > > > 'event_date' => array( > > > 'rule' => array( > > > 'date', array('Mdy') > > > ), > > > 'required' => true, > > > 'allowEmpty' => false, > > > 'message' => 'Please enter a valid date.' > > > ) > > > > Entering Sept 1, 2010 validates, but Sep 1, 2010 does not. Is that > > > correct behavior? > > > > Thank you.
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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
