Esempio n. 1
0
 protected function getDefaultParser()
 {
     return function ($value) {
         if (!preg_match('#^(?P<dd>\\d{1,2})[. -] *(?P<mm>\\d{1,2})([. -] *(?P<yyyy>\\d{4})?)?$#', $value, $matches)) {
             return NULL;
         }
         $dd = $matches['dd'];
         $mm = $matches['mm'];
         $yyyy = isset($matches['yyyy']) ? $matches['yyyy'] : date('Y');
         if (!checkdate($mm, $dd, $yyyy)) {
             return NULL;
         }
         $value = new Nette\Utils\DateTime();
         $value->setDate($yyyy, $mm, $dd);
         $value->setTime(0, 0, 0);
         return $value;
     };
 }
Esempio n. 2
0
 protected function getDefaultParser()
 {
     return function ($value) {
         if (!preg_match('#^(?P<dd>\\d{1,2})[. -] *(?P<mm>\\d{1,2})(?:[. -] *(?P<yyyy>\\d{4})?)?(?: *[ -@] *(?P<hh>\\d{1,2})[:.](?P<ii>\\d{1,2})(?:[:.](?P<ss>\\d{1,2}))?)?$#', $value, $matches)) {
             return NULL;
         }
         $dd = $matches['dd'];
         $mm = $matches['mm'];
         $yyyy = isset($matches['yyyy']) ? $matches['yyyy'] : date('Y');
         $hh = isset($matches['hh']) ? $matches['hh'] : 0;
         $ii = isset($matches['ii']) ? $matches['ii'] : 0;
         $ss = isset($matches['ss']) ? $matches['ss'] : 0;
         if (!($hh >= 0 && $hh < 24 && $ii >= 0 && $ii <= 59 && $ss >= 0 && $ss <= 59)) {
             $hh = $ii = $ss = 0;
         }
         if (!checkdate($mm, $dd, $yyyy)) {
             return NULL;
         }
         $value = new Nette\Utils\DateTime();
         $value->setDate($yyyy, $mm, $dd);
         $value->setTime($hh, $ii, $ss);
         return $value;
     };
 }
Esempio n. 3
0
 public function getForDate($year, $month, $day, array $modifier = [])
 {
     $abbr = null;
     $date = new DateTime();
     $date->setDate($year, $month, $day);
     if (!empty($modifier) && isset($modifier["abbr"])) {
         $abbr = $modifier["abbr"];
     }
     try {
         $qb = $this->eventDao->createQueryBuilder("e");
         if ($abbr !== null) {
             //		    $qb->from('App\Model\Entities\Event', 'e')
             $qb->join("e.groups", "g")->where("g.abbr = :abbr")->setParameter("abbr", $abbr);
         }
         $qq = $qb->andWhere("e.takePlaceSince <= :now")->andWhere("e.takePlaceTill >= :now")->setParameter("now", $date)->getQuery();
         $res = $qq->getResult();
         return $res;
     } catch (\Exception $ex) {
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
 }
Esempio n. 4
0
 /**
  * @Secured(resource="showEventDay")
  */
 public function actionShowEventDay($year, $month, $day)
 {
     try {
         $data = $this->eventService->getForDate($year, $month, $day);
         $date = new DateTime();
         $date->setDate($year, $month, $day);
         $this->template->date = $date->format(self::DATE_FORMAT);
         $this->template->data = $data;
     } catch (Exceptions\DataErrorException $ex) {
         $this->handleDataLoad(null, "this", $ex);
     }
 }