* Description: demonstrates using the Textual decorator */ if (!@(include 'Calendar' . DIRECTORY_SEPARATOR . 'Calendar.php')) { define('CALENDAR_ROOT', '../../'); } require_once CALENDAR_ROOT . 'Day.php'; require_once CALENDAR_ROOT . 'Month' . DIRECTORY_SEPARATOR . 'Weekdays.php'; require_once CALENDAR_ROOT . 'Decorator' . DIRECTORY_SEPARATOR . 'Textual.php'; // Could change language like this // setlocale (LC_TIME, "de_DE"); // Unix based (probably) // setlocale (LC_TIME, "ge"); // Windows echo "<hr>Calling: Calendar_Decorator_Textual::monthNames('long');<pre>"; print_r(Calendar_Decorator_Textual::monthNames('long')); echo '</pre>'; echo "<hr>Calling: Calendar_Decorator_Textual::weekdayNames('two');<pre>"; print_r(Calendar_Decorator_Textual::weekdayNames('two')); echo '</pre>'; echo "<hr>Creating: new Calendar_Day(date('Y'), date('n'), date('d'));<br />"; $Calendar = new Calendar_Day(date('Y'), date('n'), date('d')); // Decorate $Textual =& new Calendar_Decorator_Textual($Calendar); echo '<hr>Previous month is: ' . $Textual->prevMonthName('two') . '<br />'; echo 'This month is: ' . $Textual->thisMonthName('short') . '<br />'; echo 'Next month is: ' . $Textual->nextMonthName() . '<br /><hr />'; echo 'Previous day is: ' . $Textual->prevDayName() . '<br />'; echo 'This day is: ' . $Textual->thisDayName('short') . '<br />'; echo 'Next day is: ' . $Textual->nextDayName('one') . '<br /><hr />'; echo "Creating: new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - Saturday is first day of week<br />"; $Calendar = new Calendar_Month_Weekdays(date('Y'), date('n'), 6); // Decorate $Textual =& new Calendar_Decorator_Textual($Calendar);
/** * Retourne le jour du mois * @param string $format 'long' ou 'short' * @return string * @access public */ public function thisDayName($format = 'long') { $day = Calendar_Decorator_Textual::thisDayName(); $dayArray = Calendar_Decorator_Textual::weekdayNames(); $d = array_keys($dayArray, $day); switch ($format) { case 'long': return $this->longWeekDayNames[$d[0]]; break; case 'short': return $this->shortWeekDayNames[$d[0]]; } }
function testWeekdayNamesOne() { $Textual = new Calendar_Decorator_Textual($this->mockcal); $weekdayNames = array(0 => 'S', 1 => 'M', 2 => 'T', 3 => 'W', 4 => 'T', 5 => 'F', 6 => 'S'); $this->assertEqual($weekdayNames, $Textual->weekdayNames('one')); }