public function view($url) { if (preg_match('/^\\/dow(.php)?\\/' . \lib\RegExp::date(true, true) . \lib\RegExp::ext(true) . '$/', $url, $matches)) { if (\lib\RegExp::partExists('d', $matches)) { $dt_start = new \DateTime($matches['y'] . '-' . $matches['m'] . '-' . $matches['d']); $dt_end = null; } elseif (\lib\RegExp::partExists('m', $matches)) { $dt_start = new \DateTime($matches['y'] . '-' . $matches['m'] . '-01'); $dt_end = new \DateTime($matches['y'] . '-' . $matches['m'] . '-' . cal_days_in_month(CAL_GREGORIAN, $matches['m'], $matches['y'])); } else { $dt_start = new \DateTime($matches['y'] . '-01-01'); $dt_end = new \DateTime($matches['y'] . '-12-31'); } $ext = \lib\RegExp::partExists('ext', $matches) ? $matches['ext'] : null; $dow = \model\Dow::get($dt_start, $dt_end); if ($dow === false) { \lib\Error::send(404, 'This dow is not available'); } else { $this->display($dow, $ext); } } else { \lib\Error::send(404, 'No valid url, use <u>/dow/<yyyy>[/<mm>[/<dd>]]</u>'); } }
private function doCalc() { $this->output = ['date' => $this->date->format('Y-m-d'), 'east' => null, 'west' => null, 'global' => null]; $dow = \model\Dow::get($this->date); $dateTimeDayBefore = clone $this->date; $dateTimeDayBefore->modify('-1 day'); $dowDayBefore = \model\Dow::get($dateTimeDayBefore); if ($dow !== false) { $this->output['west'] = new \model\Hash($this->date, $dow); } if ($this->date->format('Y-m-d') < '2008-05-27') { $this->output['east'] = $this->output['west']; if ($dowDayBefore !== false) { $this->output['global'] = new \model\Hash($this->date, $dowDayBefore, true); } } else { if ($dowDayBefore !== false) { $this->output['east'] = new \model\Hash($this->date, $dowDayBefore); $this->output['global'] = new \model\Hash($this->date, $dowDayBefore, true); } } }