| @@ 24-29 (lines=6) @@ | ||
| 21 | class Date extends DBField { |
|
| 22 | ||
| 23 | public function setValue($value, $record = null) { |
|
| 24 | if($value === false || $value === null || (is_string($value) && !strlen($value))) { |
|
| 25 | // don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be |
|
| 26 | // saved as NULL in database |
|
| 27 | $this->value = null; |
|
| 28 | return; |
|
| 29 | } |
|
| 30 | ||
| 31 | // @todo This needs tidy up (what if you only specify a month and a year, for example?) |
|
| 32 | if(is_array($value)) { |
|
| @@ 29-34 (lines=6) @@ | ||
| 26 | class SS_Datetime extends Date implements TemplateGlobalProvider { |
|
| 27 | ||
| 28 | public function setValue($value, $record = null) { |
|
| 29 | if($value === false || $value === null || (is_string($value) && !strlen($value))) { |
|
| 30 | // don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be |
|
| 31 | // saved as NULL in database |
|
| 32 | $this->value = null; |
|
| 33 | return; |
|
| 34 | } |
|
| 35 | ||
| 36 | // Default to NZ date format - strtotime expects a US date |
|
| 37 | if(preg_match('#^([0-9]+)/([0-9]+)/([0-9]+)$#', $value, $parts)) { |
|