pluf2

pluf2 Commit Details


Date:2012-04-22 16:57:49 (12 years 11 months ago)
Author:Thomas Keller
Branch:master
Commit:0165f9ae4fe873afbf963ff5ba194bf99d9387f7
Parents: 4121ca463fa4f6f8da878aba9a9288b52743087d
Message:Check dates for validity, which is unfortunately not done by strptime internally. Now inputs like 2012-04-31 are no longer accepted.

Changes:

File differences

src/Pluf/Form/Field/Date.php
3737
3838
3939
40
41
42
43
40
41
42
43
44
45
46
47
4448
4549
4650
        parent::clean($value);
        foreach ($this->input_formats as $format) {
            if (false !== ($date = strptime($value, $format))) {
                $day = str_pad($date['tm_mday'], 2, '0', STR_PAD_LEFT);
                $month = str_pad($date['tm_mon']+1, 2, '0', STR_PAD_LEFT);
                $year = str_pad($date['tm_year']+1900, 4, '0', STR_PAD_LEFT);
                return $year.'-'.$month.'-'.$day;
                $day   = $date['tm_mday'];
                $month = $date['tm_mon'] + 1;
                $year  = $date['tm_year'] + 1900;
                if (checkdate($month, $day, $year)) {
                    return str_pad($year,  4, '0', STR_PAD_LEFT).'-'.
                           str_pad($month, 2, '0', STR_PAD_LEFT).'-'.
                           str_pad($day,   2, '0', STR_PAD_LEFT);
                }
            }
        }
        throw new Pluf_Form_Invalid(__('Enter a valid date.'));

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.22653s using 13 queries.