From: hzerres Date: Wed, 8 Sep 2010 12:57:55 +0000 (+0000) Subject: added comparison test for two dates. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=394cdf3644e89512df193c26b7fcd596a2302e37;p=gosa.git added comparison test for two dates. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19564 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/utils/class_tests.inc b/gosa-core/include/utils/class_tests.inc index e1f87a0d4..03b7bf696 100644 --- a/gosa-core/include/utils/class_tests.inc +++ b/gosa-core/include/utils/class_tests.inc @@ -292,7 +292,33 @@ class tests { return checkdate($matches[2],$matches[1],$matches[3]); } - + /* + * Compares two dates + * + * <0 => a a=b + * >0 => a>b + * + * + */ + public static function compareDate($dateA, $dateB){ + /* + * TODO: + * use $lang to check date format + */ + $tstampA = strtotime($dateA); + if($tstampA === false){ + trigger_error("Given date can not be converted to timestamp(".$dataA.") in function tests::compareDate."); + return false; + } + $tstampB = strtotime($dateB); + if($tstampB === false){ + trigger_error("Given date can not be converted to timestamp(".$dataB.") in function tests::compareDate."); + return false; + } + + return $tstampA-$tstampB; + } /* \brief Check if the specified IP address $address is inside the given network */ public static function is_in_ip_range($from, $to, $address) {