@@ -344,22 +344,22 @@ discard block |
||
344 | 344 | function prevWeek($format = 'n_in_month') |
345 | 345 | { |
346 | 346 | switch (strtolower($format)) { |
347 | - case 'int': |
|
348 | - case 'n_in_month': |
|
349 | - return ($this->firstWeek) ? null : $this->thisWeek('n_in_month') -1; |
|
350 | - case 'n_in_year': |
|
351 | - return $this->cE->getWeekNInYear( |
|
352 | - $this->cE->stampToYear($this->prevWeek), |
|
353 | - $this->cE->stampToMonth($this->prevWeek), |
|
354 | - $this->cE->stampToDay($this->prevWeek)); |
|
355 | - case 'array': |
|
356 | - return $this->toArray($this->prevWeek); |
|
357 | - case 'object': |
|
358 | - include_once CALENDAR_ROOT.'Factory.php'; |
|
359 | - return Calendar_Factory::createByTimestamp('Week', $this->prevWeek); |
|
360 | - case 'timestamp': |
|
361 | - default: |
|
362 | - return $this->prevWeek; |
|
347 | + case 'int': |
|
348 | + case 'n_in_month': |
|
349 | + return ($this->firstWeek) ? null : $this->thisWeek('n_in_month') -1; |
|
350 | + case 'n_in_year': |
|
351 | + return $this->cE->getWeekNInYear( |
|
352 | + $this->cE->stampToYear($this->prevWeek), |
|
353 | + $this->cE->stampToMonth($this->prevWeek), |
|
354 | + $this->cE->stampToDay($this->prevWeek)); |
|
355 | + case 'array': |
|
356 | + return $this->toArray($this->prevWeek); |
|
357 | + case 'object': |
|
358 | + include_once CALENDAR_ROOT.'Factory.php'; |
|
359 | + return Calendar_Factory::createByTimestamp('Week', $this->prevWeek); |
|
360 | + case 'timestamp': |
|
361 | + default: |
|
362 | + return $this->prevWeek; |
|
363 | 363 | } |
364 | 364 | } |
365 | 365 | |
@@ -374,35 +374,35 @@ discard block |
||
374 | 374 | function thisWeek($format = 'n_in_month') |
375 | 375 | { |
376 | 376 | switch (strtolower($format)) { |
377 | - case 'int': |
|
378 | - case 'n_in_month': |
|
379 | - if ($this->firstWeek) { |
|
380 | - return 1; |
|
381 | - } |
|
382 | - if ($this->lastWeek) { |
|
383 | - return $this->cE->getWeeksInMonth( |
|
377 | + case 'int': |
|
378 | + case 'n_in_month': |
|
379 | + if ($this->firstWeek) { |
|
380 | + return 1; |
|
381 | + } |
|
382 | + if ($this->lastWeek) { |
|
383 | + return $this->cE->getWeeksInMonth( |
|
384 | + $this->thisYear(), |
|
385 | + $this->thisMonth(), |
|
386 | + $this->firstDay); |
|
387 | + } |
|
388 | + return $this->cE->getWeekNInMonth( |
|
384 | 389 | $this->thisYear(), |
385 | 390 | $this->thisMonth(), |
391 | + $this->thisDay(), |
|
386 | 392 | $this->firstDay); |
387 | - } |
|
388 | - return $this->cE->getWeekNInMonth( |
|
389 | - $this->thisYear(), |
|
390 | - $this->thisMonth(), |
|
391 | - $this->thisDay(), |
|
392 | - $this->firstDay); |
|
393 | - case 'n_in_year': |
|
394 | - return $this->cE->getWeekNInYear( |
|
395 | - $this->cE->stampToYear($this->thisWeek), |
|
396 | - $this->cE->stampToMonth($this->thisWeek), |
|
397 | - $this->cE->stampToDay($this->thisWeek)); |
|
398 | - case 'array': |
|
399 | - return $this->toArray($this->thisWeek); |
|
400 | - case 'object': |
|
401 | - include_once CALENDAR_ROOT.'Factory.php'; |
|
402 | - return Calendar_Factory::createByTimestamp('Week', $this->thisWeek); |
|
403 | - case 'timestamp': |
|
404 | - default: |
|
405 | - return $this->thisWeek; |
|
393 | + case 'n_in_year': |
|
394 | + return $this->cE->getWeekNInYear( |
|
395 | + $this->cE->stampToYear($this->thisWeek), |
|
396 | + $this->cE->stampToMonth($this->thisWeek), |
|
397 | + $this->cE->stampToDay($this->thisWeek)); |
|
398 | + case 'array': |
|
399 | + return $this->toArray($this->thisWeek); |
|
400 | + case 'object': |
|
401 | + include_once CALENDAR_ROOT.'Factory.php'; |
|
402 | + return Calendar_Factory::createByTimestamp('Week', $this->thisWeek); |
|
403 | + case 'timestamp': |
|
404 | + default: |
|
405 | + return $this->thisWeek; |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
@@ -417,22 +417,22 @@ discard block |
||
417 | 417 | function nextWeek($format = 'n_in_month') |
418 | 418 | { |
419 | 419 | switch (strtolower($format)) { |
420 | - case 'int': |
|
421 | - case 'n_in_month': |
|
422 | - return ($this->lastWeek) ? null : $this->thisWeek('n_in_month') +1; |
|
423 | - case 'n_in_year': |
|
424 | - return $this->cE->getWeekNInYear( |
|
425 | - $this->cE->stampToYear($this->nextWeek), |
|
426 | - $this->cE->stampToMonth($this->nextWeek), |
|
427 | - $this->cE->stampToDay($this->nextWeek)); |
|
428 | - case 'array': |
|
429 | - return $this->toArray($this->nextWeek); |
|
430 | - case 'object': |
|
431 | - include_once CALENDAR_ROOT.'Factory.php'; |
|
432 | - return Calendar_Factory::createByTimestamp('Week', $this->nextWeek); |
|
433 | - case 'timestamp': |
|
434 | - default: |
|
435 | - return $this->nextWeek; |
|
420 | + case 'int': |
|
421 | + case 'n_in_month': |
|
422 | + return ($this->lastWeek) ? null : $this->thisWeek('n_in_month') +1; |
|
423 | + case 'n_in_year': |
|
424 | + return $this->cE->getWeekNInYear( |
|
425 | + $this->cE->stampToYear($this->nextWeek), |
|
426 | + $this->cE->stampToMonth($this->nextWeek), |
|
427 | + $this->cE->stampToDay($this->nextWeek)); |
|
428 | + case 'array': |
|
429 | + return $this->toArray($this->nextWeek); |
|
430 | + case 'object': |
|
431 | + include_once CALENDAR_ROOT.'Factory.php'; |
|
432 | + return Calendar_Factory::createByTimestamp('Week', $this->nextWeek); |
|
433 | + case 'timestamp': |
|
434 | + default: |
|
435 | + return $this->nextWeek; |
|
436 | 436 | } |
437 | 437 | } |
438 | 438 |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | $stamp = mktime(0, 0, 0, $i, 1, 2003); |
97 | 97 | $month = strftime($formats[$format], $stamp); |
98 | 98 | switch($format) { |
99 | - case 'one': |
|
100 | - $month = substr($month, 0, 1); |
|
101 | - break; |
|
102 | - case 'two': |
|
103 | - $month = substr($month, 0, 2); |
|
104 | - break; |
|
99 | + case 'one': |
|
100 | + $month = substr($month, 0, 1); |
|
101 | + break; |
|
102 | + case 'two': |
|
103 | + $month = substr($month, 0, 2); |
|
104 | + break; |
|
105 | 105 | } |
106 | 106 | $months[$i] = $month; |
107 | 107 | } |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | $stamp = mktime(0, 0, 0, 11, $i+2, 2003); |
134 | 134 | $day = strftime($formats[$format], $stamp); |
135 | 135 | switch($format) { |
136 | - case 'one': |
|
137 | - $day = substr($day, 0, 1); |
|
138 | - break; |
|
139 | - case 'two': |
|
140 | - $day = substr($day, 0, 2); |
|
141 | - break; |
|
136 | + case 'one': |
|
137 | + $day = substr($day, 0, 1); |
|
138 | + break; |
|
139 | + case 'two': |
|
140 | + $day = substr($day, 0, 2); |
|
141 | + break; |
|
142 | 142 | } |
143 | 143 | $days[$i] = $day; |
144 | 144 | } |
@@ -87,13 +87,13 @@ discard block |
||
87 | 87 | { |
88 | 88 | static $engine = false; |
89 | 89 | switch (CALENDAR_ENGINE) { |
90 | - case 'PearDate': |
|
91 | - $class = 'Calendar_Engine_PearDate'; |
|
92 | - break; |
|
93 | - case 'UnixTS': |
|
94 | - default: |
|
95 | - $class = 'Calendar_Engine_UnixTS'; |
|
96 | - break; |
|
90 | + case 'PearDate': |
|
91 | + $class = 'Calendar_Engine_PearDate'; |
|
92 | + break; |
|
93 | + case 'UnixTS': |
|
94 | + default: |
|
95 | + $class = 'Calendar_Engine_UnixTS'; |
|
96 | + break; |
|
97 | 97 | } |
98 | 98 | if (!$engine) { |
99 | 99 | if (!class_exists($class)) { |
@@ -340,19 +340,19 @@ discard block |
||
340 | 340 | function returnValue($returnType, $format, $stamp, $default) |
341 | 341 | { |
342 | 342 | switch (strtolower($format)) { |
343 | - case 'int': |
|
344 | - return $default; |
|
345 | - case 'array': |
|
346 | - return $this->toArray($stamp); |
|
347 | - break; |
|
348 | - case 'object': |
|
349 | - include_once CALENDAR_ROOT.'Factory.php'; |
|
350 | - return Calendar_Factory::createByTimestamp($returnType, $stamp); |
|
351 | - break; |
|
352 | - case 'timestamp': |
|
353 | - default: |
|
354 | - return $stamp; |
|
355 | - break; |
|
343 | + case 'int': |
|
344 | + return $default; |
|
345 | + case 'array': |
|
346 | + return $this->toArray($stamp); |
|
347 | + break; |
|
348 | + case 'object': |
|
349 | + include_once CALENDAR_ROOT.'Factory.php'; |
|
350 | + return Calendar_Factory::createByTimestamp($returnType, $stamp); |
|
351 | + break; |
|
352 | + case 'timestamp': |
|
353 | + default: |
|
354 | + return $stamp; |
|
355 | + break; |
|
356 | 356 | } |
357 | 357 | } |
358 | 358 |
@@ -95,50 +95,50 @@ |
||
95 | 95 | { |
96 | 96 | $firstDay = defined('CALENDAR_FIRST_DAY_OF_WEEK') ? CALENDAR_FIRST_DAY_OF_WEEK : 1; |
97 | 97 | switch ($type) { |
98 | - case 'Day': |
|
99 | - include_once CALENDAR_ROOT.'Day.php'; |
|
100 | - return new Calendar_Day($y, $m, $d); |
|
101 | - case 'Month': |
|
102 | - // Set default state for which month type to build |
|
103 | - if (!defined('CALENDAR_MONTH_STATE')) { |
|
104 | - define('CALENDAR_MONTH_STATE', CALENDAR_USE_MONTH); |
|
105 | - } |
|
106 | - switch (CALENDAR_MONTH_STATE) { |
|
107 | - case CALENDAR_USE_MONTH_WEEKDAYS: |
|
108 | - include_once CALENDAR_ROOT.'Month/Weekdays.php'; |
|
109 | - $class = 'Calendar_Month_Weekdays'; |
|
110 | - break; |
|
111 | - case CALENDAR_USE_MONTH_WEEKS: |
|
112 | - include_once CALENDAR_ROOT.'Month/Weeks.php'; |
|
113 | - $class = 'Calendar_Month_Weeks'; |
|
114 | - break; |
|
115 | - case CALENDAR_USE_MONTH: |
|
116 | - default: |
|
117 | - include_once CALENDAR_ROOT.'Month.php'; |
|
118 | - $class = 'Calendar_Month'; |
|
119 | - break; |
|
120 | - } |
|
98 | + case 'Day': |
|
99 | + include_once CALENDAR_ROOT.'Day.php'; |
|
100 | + return new Calendar_Day($y, $m, $d); |
|
101 | + case 'Month': |
|
102 | + // Set default state for which month type to build |
|
103 | + if (!defined('CALENDAR_MONTH_STATE')) { |
|
104 | + define('CALENDAR_MONTH_STATE', CALENDAR_USE_MONTH); |
|
105 | + } |
|
106 | + switch (CALENDAR_MONTH_STATE) { |
|
107 | + case CALENDAR_USE_MONTH_WEEKDAYS: |
|
108 | + include_once CALENDAR_ROOT.'Month/Weekdays.php'; |
|
109 | + $class = 'Calendar_Month_Weekdays'; |
|
110 | + break; |
|
111 | + case CALENDAR_USE_MONTH_WEEKS: |
|
112 | + include_once CALENDAR_ROOT.'Month/Weeks.php'; |
|
113 | + $class = 'Calendar_Month_Weeks'; |
|
114 | + break; |
|
115 | + case CALENDAR_USE_MONTH: |
|
116 | + default: |
|
117 | + include_once CALENDAR_ROOT.'Month.php'; |
|
118 | + $class = 'Calendar_Month'; |
|
119 | + break; |
|
120 | + } |
|
121 | 121 | return new $class($y, $m, $firstDay); |
122 | - case 'Week': |
|
123 | - include_once CALENDAR_ROOT.'Week.php'; |
|
124 | - return new Calendar_Week($y, $m, $d, $firstDay); |
|
125 | - case 'Hour': |
|
126 | - include_once CALENDAR_ROOT.'Hour.php'; |
|
127 | - return new Calendar_Hour($y, $m, $d, $h); |
|
128 | - case 'Minute': |
|
129 | - include_once CALENDAR_ROOT.'Minute.php'; |
|
130 | - return new Calendar_Minute($y, $m, $d, $h, $i); |
|
131 | - case 'Second': |
|
132 | - include_once CALENDAR_ROOT.'Second.php'; |
|
133 | - return new Calendar_Second($y, $m, $d, $h, $i, $s); |
|
134 | - case 'Year': |
|
135 | - include_once CALENDAR_ROOT.'Year.php'; |
|
136 | - return new Calendar_Year($y); |
|
137 | - default: |
|
138 | - include_once 'PEAR.php'; |
|
139 | - PEAR::raiseError('Calendar_Factory::create() unrecognised type: '.$type, |
|
140 | - null, PEAR_ERROR_TRIGGER, E_USER_NOTICE, 'Calendar_Factory::create()'); |
|
141 | - return false; |
|
122 | + case 'Week': |
|
123 | + include_once CALENDAR_ROOT.'Week.php'; |
|
124 | + return new Calendar_Week($y, $m, $d, $firstDay); |
|
125 | + case 'Hour': |
|
126 | + include_once CALENDAR_ROOT.'Hour.php'; |
|
127 | + return new Calendar_Hour($y, $m, $d, $h); |
|
128 | + case 'Minute': |
|
129 | + include_once CALENDAR_ROOT.'Minute.php'; |
|
130 | + return new Calendar_Minute($y, $m, $d, $h, $i); |
|
131 | + case 'Second': |
|
132 | + include_once CALENDAR_ROOT.'Second.php'; |
|
133 | + return new Calendar_Second($y, $m, $d, $h, $i, $s); |
|
134 | + case 'Year': |
|
135 | + include_once CALENDAR_ROOT.'Year.php'; |
|
136 | + return new Calendar_Year($y); |
|
137 | + default: |
|
138 | + include_once 'PEAR.php'; |
|
139 | + PEAR::raiseError('Calendar_Factory::create() unrecognised type: '.$type, |
|
140 | + null, PEAR_ERROR_TRIGGER, E_USER_NOTICE, 'Calendar_Factory::create()'); |
|
141 | + return false; |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 |