static function age($value, $min = null, $max = null) { $time = new Time($value); $age = $time->diff(new Time('now')); if (Tool::isInt($max) && $age->y > $max) { Debug::toss(['type' => 'age_max', 'detail' => $max], 'InputException'); } if (Tool::isInt($min) && $age->y < $min) { Debug::toss(['type' => 'age_min', 'detail' => $min], 'InputException'); } }
/** @param format DateTime::format() format @param zone The zone of the output time @param relation see php relative times; ex "-1 day". */ function format($format, $zone = null, $relation = null) { if ($relation) { $newDate = new Time($relation, $this->getTimezone(), $this); return $newDate->format($format, $zone); } if ($zone) { $currentZone = $this->getTimezone(); $this->setZone($zone); $return = parent::format($format); $this->setZone($currentZone); return $return; } else { return parent::format($format); } }