cvs: pear /Calendar Calendar.php
| From: | Lorenzo Alberton | Date: | Sat, 22 Oct 2005 10:07:11 +0000 |
| Subject: | cvs: pear /Calendar Calendar.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-35777@lists.php.net to get a copy of this message | ||
quipo Sat Oct 22 06:07:11 2005 EDT
Modified files:
/pear/Calendar Calendar.php
Log:
added defineFirstDayOfWeek($firstDay) method
http://cvs.php.net/diff.php/pear/Calendar/Calendar.php?r1=1.2&r2=1.3&ty=u
Index: pear/Calendar/Calendar.php
diff -u pear/Calendar/Calendar.php:1.2 pear/Calendar/Calendar.php:1.3
--- pear/Calendar/Calendar.php:1.2 Thu Jun 24 06:12:50 2004
+++ pear/Calendar/Calendar.php Sat Oct 22 06:07:11 2005
@@ -18,11 +18,11 @@
// | Lorenzo Alberton <l dot alberton at quipo dot it> |
// +----------------------------------------------------------------------+
//
-// $Id: Calendar.php,v 1.2 2004/06/24 10:12:50 quipo Exp $
+// $Id: Calendar.php,v 1.3 2005/10/22 10:07:11 quipo Exp $
//
/**
* @package Calendar
- * @version $Id: Calendar.php,v 1.2 2004/06/24 10:12:50 quipo Exp $
+ * @version $Id: Calendar.php,v 1.3 2005/10/22 10:07:11 quipo Exp $
*/
/**
@@ -408,9 +408,9 @@
/**
* Returns a reference to the current Calendar_Engine being used. Useful
- * for Calendar_Table_Helper and Caledar_Validator
+ * for Calendar_Table_Helper and Calendar_Validator
* @return object implementing Calendar_Engine_Inteface
- * @access private
+ * @access protected
*/
function & getEngine()
{
@@ -418,6 +418,37 @@
}
/**
+ * Set the CALENDAR_FIRST_DAY_OF_WEEK constant to the $firstDay value
+ * if the constant is not set yet.
+ * @throws E_USER_WARNING this method throws a WARNING if the
+ * CALENDAR_FIRST_DAY_OF_WEEK constant is already defined and
+ * the $firstDay parameter is set to a different value
+ * @param integer $firstDay first day of the week (0=sunday, 1=monday, ...)
+ * @return integer
+ * @access protected
+ */
+ function defineFirstDayOfWeek($firstDay = null)
+ {
+ if (defined('CALENDAR_FIRST_DAY_OF_WEEK')) {
+ if (!is_null($firstDay) && ($firstDay != CALENDAR_FIRST_DAY_OF_WEEK)) {
+ $msg = 'CALENDAR_FIRST_DAY_OF_WEEK constant already defined.'
+ .' The $firstDay parameter will be ignored.';
+ trigger_error($msg, E_USER_WARNING);
+ }
+ return CALENDAR_FIRST_DAY_OF_WEEK;
+ }
+ if (is_null($firstDay)) {
+ $firstDay = $this->cE->getFirstDayOfWeek(
+ $this->thisYear(),
+ $this->thisMonth(),
+ $this->thisDay()
+ );
+ }
+ define ('CALENDAR_FIRST_DAY_OF_WEEK', $firstDay);
+ return CALENDAR_FIRST_DAY_OF_WEEK;
+ }
+
+ /**
* Returns the value for the previous year
* @param string return value format ['int' | 'timestamp' |
'object' | 'array']
* @return int e.g. 2002 or timestamp