cvs: php4 /pear/Date Calc.php
| From: | Tomas V.V.Cox | Date: | Thu, 06 Jun 2002 11:45:12 +0000 |
| Subject: | cvs: php4 /pear/Date Calc.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4453@lists.php.net to get a copy of this message | ||
cox Thu Jun 6 07:45:12 2002 EDT
Modified files:
/php4/pear/Date Calc.php
Log:
Added method Date_Calc::compareDates($day1,$month1,$year1,$day2,$month2,$year2)
Index: php4/pear/Date/Calc.php
diff -u php4/pear/Date/Calc.php:1.19 php4/pear/Date/Calc.php:1.20
--- php4/pear/Date/Calc.php:1.19 Thu Jun 6 07:38:09 2002
+++ php4/pear/Date/Calc.php Thu Jun 6 07:45:12 2002
@@ -755,6 +755,29 @@
} // end func dateDiff
/**
+ * Compares two dates
+ *
+ * @param string $day1 day in format DD
+ * @param string $month1 month in format MM
+ * @param string $year1 year in format CCYY
+ * @param string $day2 day in format DD
+ * @param string $month2 month in format MM
+ * @param string $year2 year in format CCYY
+ *
+ * @access public
+ * @return int 0 on equality, 1 if date 1 is greater, -1 if smaller
+ */
+ function compareDates($day1,$month1,$year1,$day2,$month2,$year2)
+ {
+ $ndays1 = Date_Calc::dateToDays($day1, $month1, $year1);
+ $ndays2 = Date_Calc::dateToDays($day2, $month2, $year2);
+ if ($ndays1 == $ndays2) {
+ return 0;
+ }
+ return ($ndays1 > $ndays2) ? 1 : -1;
+ }
+
+ /**
* Find the number of days in the given month.
*
* @param string month in format MM, default current local month