Esempio n. 1
0
 private function generateDays()
 {
     $weekStart = new \TYPO3\CMS\Cal\Model\CalDate(\TYPO3\CMS\Cal\Utility\Functions::getDayByWeek($this->year, $this->week, DATE_CALC_BEGIN_WEEKDAY));
     $this->weekStart = $weekStart->format('%Y%m%d');
     $this->month = $weekStart->getMonth();
     if ($this->getParentMonth() < 0) {
         $this->setParentMonth($this->month);
     }
     $this->days = array();
     $this->alldays = array();
     $this->dayNums = array();
     for ($i = 0; $i < 7; $i++) {
         $this->dayNums[$i] = $weekStart->day;
         $weekStartFormated = $weekStart->format('%Y%m%d');
         $this->days[$weekStartFormated] = new \TYPO3\CMS\Cal\View\NewDayView($weekStart->day, $weekStart->month, $weekStart->year, $this->getParentMonth());
         $this->alldays[$weekStartFormated] = array();
         $weekStart->addSeconds(86400);
     }
     $this->weekEnd = $weekStart->format('%Y%m%d');
 }
Esempio n. 2
0
 public function testFirstDayOfWeek1OfYear2013WeekstartSunday_is_20130304()
 {
     $this->assertEquals('20130304', \TYPO3\CMS\Cal\Utility\Functions::getDayByWeek(2013, 10, 1));
 }
Esempio n. 3
0
 /**
  * 
  */
 public function getParamsFromSession()
 {
     if (!$this->piVars['view']) {
         if ($this->piVars['week']) {
             $this->piVars['view'] = 'week';
         } else {
             if ($this->piVars['day']) {
                 $this->piVars['view'] = 'day';
             } else {
                 if ($this->piVars['month']) {
                     $this->piVars['view'] = 'month';
                 } else {
                     if ($this->piVars['year']) {
                         $this->piVars['view'] = 'year';
                     }
                 }
             }
         }
     }
     if ($this->conf['dontListenToPiVars']) {
         $this->piVars = array();
     } else {
         foreach ((array) $_SESSION[$this->prefixId] as $key => $value) {
             if (!array_key_exists($key, $this->piVars)) {
                 $this->piVars[$key] = $value;
             }
         }
     }
     if (!$this->piVars['getdate'] && !$this->piVars['week'] && !$this->piVars['year'] && $this->conf['_DEFAULT_PI_VARS.']['getdate']) {
         $this->piVars['getdate'] = $this->conf['_DEFAULT_PI_VARS.']['getdate'];
     }
     if (!$this->piVars['getdate']) {
         if ($this->piVars['week']) {
             $this->piVars['getdate'] = \TYPO3\CMS\Cal\Utility\Functions::getDayByWeek($this->piVars['year'], $this->piVars['week'], $this->piVars['weekday']);
             unset($this->piVars['year']);
             unset($this->piVars['week']);
             unset($this->piVars['weekday']);
         } else {
             $date = new \TYPO3\CMS\Cal\Model\CalDate();
             $date->setTZbyID('UTC');
             if (!$this->piVars['year']) {
                 $this->piVars['year'] = $date->format('%Y');
             }
             if (!$this->piVars['month']) {
                 $this->piVars['month'] = $date->format('%m');
             }
             if (!$this->piVars['day']) {
                 $this->piVars['day'] = $date->format('%d');
             }
             if ($this->piVars['month'] == 2) {
                 if (($this->piVars['year'] % 400 == 0 || $this->piVars['year'] % 4 == 0 && $this->piVars['year'] % 100 != 0) && $this->piVars['day'] > 29) {
                     $this->piVars['day'] = 29;
                 } else {
                     if ($this->piVars['day'] > 28) {
                         $this->piVars['day'] = 28;
                     }
                 }
             } else {
                 if (in_array($this->piVars['month'], array(4, 6, 9, 11)) && $this->piVars['day'] > 30) {
                     $this->piVars['day'] = 30;
                 }
             }
             $this->piVars['getdate'] = str_pad((int) $this->piVars['year'], 4, "0", STR_PAD_LEFT) . str_pad((int) $this->piVars['month'], 2, "0", STR_PAD_LEFT) . str_pad((int) $this->piVars['day'], 2, "0", STR_PAD_LEFT);
             unset($this->piVars['year']);
             unset($this->piVars['month']);
             unset($this->piVars['day']);
         }
     }
     unset($_SESSION[$this->prefixId]);
 }