[pLog-svn] r2953 - plog/trunk/class/data/Date
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Wed Feb 15 16:38:14 GMT 2006
Author: oscar
Date: 2006-02-15 16:38:13 +0000 (Wed, 15 Feb 2006)
New Revision: 2953
Modified:
plog/trunk/class/data/Date/Calc.class.php
Log:
Date_Calc::daysInMoth is needed
Modified: plog/trunk/class/data/Date/Calc.class.php
===================================================================
--- plog/trunk/class/data/Date/Calc.class.php 2006-02-15 16:25:23 UTC (rev 2952)
+++ plog/trunk/class/data/Date/Calc.class.php 2006-02-15 16:38:13 UTC (rev 2953)
@@ -85,29 +85,29 @@
// * @return boolean true/false
// */
//
-// function isLeapYear($year='')
-// {
-// if (empty($year)) {
-// $year = Date_Calc::dateNow('%Y');
-// }
+ function isLeapYear($year='')
+ {
+ if (empty($year)) {
+ $year = Date_Calc::dateNow('%Y');
+ }
+
+ if (preg_match('/\D/',$year)) {
+ return false;
+ }
+
+ if ($year < 1000) {
+ return false;
+ }
+
+ if ($year < 1582) {
+ // pre Gregorio XIII - 1582
+ return ($year % 4 == 0);
+ } else {
+ // post Gregorio XIII - 1582
+ return ( (($year % 4 == 0) and ($year % 100 != 0)) or ($year % 400 == 0) );
+ }
+ } // end func isLeapYear
//
-// if (preg_match('/\D/',$year)) {
-// return false;
-// }
-//
-// if ($year < 1000) {
-// return false;
-// }
-//
-// if ($year < 1582) {
-// // pre Gregorio XIII - 1582
-// return ($year % 4 == 0);
-// } else {
-// // post Gregorio XIII - 1582
-// return ( (($year % 4 == 0) and ($year % 100 != 0)) or ($year % 400 == 0) );
-// }
-// } // end func isLeapYear
-//
// /**
// * Determines if given date is a future date from now.
// *
@@ -811,32 +811,32 @@
// * @return int number of days
// */
//
-// function daysInMonth($month='',$year='')
-// {
-// if (empty($year)) {
-// $year = Date_Calc::dateNow('%Y');
-// }
-// if (empty($month)) {
-// $month = Date_Calc::dateNow('%m');
-// }
+ function daysInMonth($month='',$year='')
+ {
+ if (empty($year)) {
+ $year = Date_Calc::dateNow('%Y');
+ }
+ if (empty($month)) {
+ $month = Date_Calc::dateNow('%m');
+ }
+
+ if ($year == 1582 && $month == 10) {
+ return 21; // October 1582 only had 1st-4th and 15th-31st
+ }
+
+ if ($month == 2) {
+ if (Date_Calc::isLeapYear($year)) {
+ return 29;
+ } else {
+ return 28;
+ }
+ } elseif ($month == 4 or $month == 6 or $month == 9 or $month == 11) {
+ return 30;
+ } else {
+ return 31;
+ }
+ } // end func daysInMonth
//
-// if ($year == 1582 && $month == 10) {
-// return 21; // October 1582 only had 1st-4th and 15th-31st
-// }
-//
-// if ($month == 2) {
-// if (Date_Calc::isLeapYear($year)) {
-// return 29;
-// } else {
-// return 28;
-// }
-// } elseif ($month == 4 or $month == 6 or $month == 9 or $month == 11) {
-// return 30;
-// } else {
-// return 31;
-// }
-// } // end func daysInMonth
-//
// /**
// * Returns the number of rows on a calendar month. Useful for
// * determining the number of rows when displaying a typical
More information about the pLog-svn
mailing list