Better handling of dates when registering children

This commit is contained in:
Deon George
2014-10-23 10:05:32 +11:00
parent 48debfbd6c
commit 6eb0b2f8dd
3 changed files with 63 additions and 8 deletions

View File

@@ -21,7 +21,7 @@ class Model_Child extends ORM {
public function filters() {
return Arr::merge(parent::filters(),array(
'dob'=>array(array('strtotime', array(':value'))),
'dob'=>array(array(array($this,'date'), array(':value'))),
));
}
@@ -53,6 +53,10 @@ class Model_Child extends ORM {
return $format == '%w' ? sprintf('%02dw',$dob->diff($today)->days/7) : $dob->diff($today)->format($format);
}
public function date($value) {
return is_numeric($value) ? $value : strtotime($value);
}
public function date_enrol_min() {
$dob = $this->_dob();
$dob->add(new DateInterval('P'.$this->_start));