From 394cdf3644e89512df193c26b7fcd596a2302e37 Mon Sep 17 00:00:00 2001 From: hzerres Date: Wed, 8 Sep 2010 12:57:55 +0000 Subject: [PATCH] added comparison test for two dates. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19564 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/utils/class_tests.inc | 28 ++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) 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) { -- 2.30.2