summaryrefslogtreecommitdiff
path: root/protected/components/DateCompareValidator.php
diff options
context:
space:
mode:
authorPatrick Seeger <pseeger@ccwn.org>2012-05-20 16:58:26 +0200
committerPatrick Seeger <pseeger@ccwn.org>2012-05-20 16:58:26 +0200
commit4f959ffc80e64dc9ee8383826a546723d97305d9 (patch)
tree3a0704c0e3a9f44746739ccffa0d64acc5ab172d /protected/components/DateCompareValidator.php
parentacec2b5dc35302147f9a9c73d837dce2f3f9958e (diff)
parent9aad228e1af661b9b39df83700d27e71697dc66f (diff)
Merge branch 'master' of ssh://proxy.ccwn.org:9044/home/ccwn/git-repos/admin.astaf.de
Diffstat (limited to 'protected/components/DateCompareValidator.php')
-rw-r--r--protected/components/DateCompareValidator.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/protected/components/DateCompareValidator.php b/protected/components/DateCompareValidator.php
index c013382..13a4126 100644
--- a/protected/components/DateCompareValidator.php
+++ b/protected/components/DateCompareValidator.php
@@ -40,15 +40,24 @@ class DateCompareValidator extends CValidator {
return;
}
- $start = CDateTimeParser::parse($object->$attribute, $this->format);
+ $start = $object->$attribute;
+ $end = $this->compareValue;
- $end = CDateTimeParser::parse($this->compareValue, $this->format);
+ $pattern = '/[0-9]{2}\.[0-9]{2}\.[0-9]{4}\s[0-9]{2}:[0-9]{2}/';
+ if (preg_match($pattern, $start)) {
+ $start = CDateTimeParser::parse($start, "dd.MM.yyyy HH:mm");
+ }
+ if (preg_match($pattern, $end)) {
+ $end = CDateTimeParser::parse($end, "dd.MM.yyyy HH:mm");
+ }
//a little php trick - safe than eval and easier than a big switch statement
if (version_compare($start, $end, $this->operator)) {
+ Yii::trace('Input value: '.$start.' - compare value: '.$end.' - operator: '.$this->operator.' - result: OK', 'ccwn.astaf.date.validate');
return;
} else {
+ Yii::trace('Input value: '.$start.' - compare value: '.$end.' - operator: '.$this->operator.' - result: FAIL', 'ccwn.astaf.date.validate');
$message = $this->message !== null ? $this->message : Yii::t('astaf', 'The value of {attribute} ({value}) is not {operator} {compareAttribute} ({compareValue}).');
$this->addError($object, $attribute, $message, array('{operator}'=>$this->operator, '{compareValue}'=>$this->compareValue, '{value}'=>$object->$attribute, '{compareAttribute}'=>($object->getAttributeLabel($this->compareAttribute))));
}