summaryrefslogtreecommitdiff
path: root/manager/application
diff options
context:
space:
mode:
authorMichael Tänzer <neo@nhng.de>2011-06-21 01:12:54 +0200
committerMichael Tänzer <neo@nhng.de>2011-06-21 01:12:54 +0200
commit9dfc0e4078003582b43e56a2f5c74474947048fb (patch)
treedcf2a3fa7e9fca5978100d281ea837e572ce746c /manager/application
parent445b9b133f9e88099422892693966ae2a6f5212e (diff)
downloadcacert-mgr-9dfc0e4078003582b43e56a2f5c74474947048fb.tar.gz
cacert-mgr-9dfc0e4078003582b43e56a2f5c74474947048fb.tar.xz
cacert-mgr-9dfc0e4078003582b43e56a2f5c74474947048fb.zip
Correctly calculate age
Signed-off-by: Michael Tänzer <neo@nhng.de>
Diffstat (limited to 'manager/application')
-rw-r--r--manager/application/models/User.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/manager/application/models/User.php b/manager/application/models/User.php
index 55eeadb..7b7a519 100644
--- a/manager/application/models/User.php
+++ b/manager/application/models/User.php
@@ -168,7 +168,16 @@ class Default_Model_User {
*/
public function getAge() {
$now = new Zend_Date();
- return $now->sub($this->getDob())->toValue(Zend_Date::YEAR);
+ $dob = $this->getDob();
+ $age = $now->get(Zend_Date::YEAR) - $dob->get(Zend_Date::YEAR);
+
+ // Did we have a happy birthday already this year?
+ $dob->setYear($now);
+ if ($dob->compare($now) > 0) {
+ $age -= 1;
+ }
+
+ return $age;
}
/**