diff --git date_api.module date_api.module index 8639596..3292143 100644 --- date_api.module +++ date_api.module @@ -581,10 +581,14 @@ class DateObject extends DateTime { public function arrayErrors($arr) { $errors = array(); $now = date_now(); + + $default_month = !empty($arr['month']) ? $arr['month'] : $now->format('n'); + $default_year = !empty($arr['year']) ? $arr['year'] : $now->format('Y'); + foreach ($arr as $part => $value) { // Avoid false errors when a numeric value is input as a string by forcing it numeric. $value = intval($value); - if (!empty($value) && $this->forceValid($part, $value, 'now', $now->format('n'), $now->format('Y')) != $value) { + if (!empty($value) && $this->forceValid($part, $value, 'now', $default_month, $default_year) != $value) { // Use a switchcase to make translation easier by providing a different message for each part. switch($part) { case 'year':