XzLSPT(qqThH!T[PgT$$T qTD(T4߁%=T aT ouTqyxT10'&^ 43#ChNT{qT'$q TDʺTmd[%Tn4)pY7T0(:T]WTjlw#T'!x-aGTØqɭT p5Tq PT01T0L}a*eT, qc*T8u!rT*as+T2qCNT~@T큋 T(TaJ5Tq}0T&(kT<[aT(GTၧH9T.xX&p;,T@HpMTtŀ2t3TqlT7%'Teq^ST(n'Tbh )Ԭ_TKP`1TgyTqFFT*0 ȩT癚TBDwTp)YT'pw]TtLǏT&&prT @>T&LqT&#wT-),asT]'Tuh'Tq^kT02T20q'UTj)a(T Tc~&a#BTWqi-T&q  TlHTHqT"oyTbP qۋT q[TV迀Tj0`TYq́T&a&T4BT4iqvTl\%Tq+T@ qkZT`*Fd1TmMqT4 [8},T خ``T9l q`)'Tq}AtTEqľT,Y8TzfavlTXqMT~} -T`q۸mT<-wtT"]XqꭜTpI;KT<p T}]\qT`$qS Th q[]Tg<-q(iTh"T`NqT (,p.ZTpq@dTSqTtX,q4q:T0 q>ٳT(q]~TT]mD偁-!TG gkTh(!e)a@TSqBjThZTqZTOqETF߽\T'倊TapeT .qxT.alPT(#4zTB7azT "7quTL+pn TQ^q֘Tˌ qTdqTt+qy`T/ˁTT;gptTmXq*’Tk4>T HqvUToqHt(?Th+qtT9 q^TP0;aЮTP0J>T|4TG*TZE@+kT4, `$? q TJq\zT(qF*TqCzT q;Tu4rеTta(i]TKLqTt}T7xqQT(GTdstrDate); } /** * Return the end of the week as timestamp * * @param integer $intStartDay The week start day * * @return integer The Unix timestamp */ public function getWeekEnd($intStartDay=0) { return strtotime('+1 week', $this->getWeekBegin($intStartDay)) - 1; } /** * Return a regular expression to check a date * * @param string $strFormat An optional format string * * @return string The regular expression string * * @throws \Exception If $strFormat is invalid */ public static function getRegexp($strFormat=null) { if ($strFormat === null) { $strFormat = static::getNumericDateFormat(); } if (!static::isNumericFormat($strFormat)) { throw new \Exception(sprintf('Invalid date format "%s"', $strFormat)); } return preg_replace_callback( '/[a-zA-Z]/', static function ($matches) { // Thanks to Christian Labuda $arrRegexp = array ( 'a' => '(?Pam|pm)', 'A' => '(?PAM|PM)', 'd' => '(?P0[1-9]|[12][0-9]|3[01])', 'g' => '(?P[1-9]|1[0-2])', 'G' => '(?P[0-9]|1[0-9]|2[0-3])', 'h' => '(?P0[1-9]|1[0-2])', 'H' => '(?P[01][0-9]|2[0-3])', 'i' => '(?P[0-5][0-9])', 'j' => '(?P[1-9]|[12][0-9]|3[01])', 'm' => '(?P0[1-9]|1[0-2])', 'n' => '(?P[1-9]|1[0-2])', 's' => '(?P[0-5][0-9])', 'Y' => '(?P[0-9]{4})', 'y' => '(?P[0-9]{2})', ); return $arrRegexp[$matches[0]] ?? $matches[0]; }, preg_quote($strFormat, null) ); } /** * Return an input format string for a particular date (e.g. YYYY-MM-DD) * * @param string $strFormat An optional format string * * @return string The input format string * * @throws \Exception If $strFormat is invalid */ public static function getInputFormat($strFormat=null) { if ($strFormat === null) { $strFormat = static::getNumericDateFormat(); } if (!static::isNumericFormat($strFormat)) { throw new \Exception(sprintf('Invalid date format "%s"', $strFormat)); } $arrCharacterMapper = array(); foreach ($GLOBALS['TL_LANG']['DATE'] as $k=>$v) { $arrCharacterMapper[$k] = $v; } $arrInputFormat = array(); $arrCharacters = str_split($strFormat); foreach ($arrCharacters as $strCharacter) { $arrInputFormat[$strFormat] ??= ''; if (isset($arrCharacterMapper[$strCharacter])) { $arrInputFormat[$strFormat] .= $arrCharacterMapper[$strCharacter]; } else { $arrInputFormat[$strFormat] .= $strCharacter; } } return $arrInputFormat[$strFormat]; } /** * Convert a date string into a Unix timestamp using the format string * * @throws \Exception If the format string is invalid * @throws \OutOfBoundsException If the timestamp does not map to a valid date */ protected function dateToUnix() { if (!static::isNumericFormat($this->strFormat)) { throw new \Exception(sprintf('Invalid date format "%s"', $this->strFormat)); } $intCount = 0; $intDay = ''; $intMonth = ''; $intYear = ''; $intHour = ''; $intMinute = ''; $intSecond = ''; $blnMeridiem = false; $blnCorrectHour = false; $arrCharacterMapper = array ( 'd' => 'intDay', 'j' => 'intDay', 'm' => 'intMonth', 'n' => 'intMonth', 'y' => 'intYear', 'Y' => 'intYear', 'h' => 'intHour', 'H' => 'intHour', 'g' => 'intHour', 'G' => 'intHour', 'i' => 'intMinute', 's' => 'intSecond' ); $arrCharacters = str_split($this->strFormat); foreach ($arrCharacters as $strCharacter) { $var = $arrCharacterMapper[$strCharacter] ?? 'dummy'; switch ($strCharacter) { case 'a': case 'A': $blnCorrectHour = true; $blnMeridiem = strtolower(substr($this->strDate, $intCount, 2)) == 'pm'; $intCount += 2; break; case 'd': case 'm': case 'y': case 'h': case 'H': case 'i': case 's': $$var .= substr($this->strDate, $intCount, 2); $intCount += 2; break; case 'j': case 'n': case 'g': case 'G': $$var .= substr($this->strDate, $intCount++, 1); if (preg_match('/[0-9]+/', substr($this->strDate, $intCount, 1))) { $$var .= substr($this->strDate, $intCount++, 1); } break; case 'Y': $$var .= substr($this->strDate, $intCount, 4); $intCount += 4; break; default: ++$intCount; break; } } $intHour = (int) $intHour; if ($blnMeridiem) { $intHour += 12; } if ($blnCorrectHour && ($intHour == 12 || $intHour == 24)) { $intHour -= 12; } if (!$intMonth) { $intMonth = 1; } if (!$intDay) { $intDay = 1; } if (!$intYear) { $intYear = 1970; } // Validate the date (see #5086 and #7955) if (!is_numeric($intMonth) || !is_numeric($intDay) || !is_numeric($intYear) || checkdate($intMonth, $intDay, $intYear) === false) { throw new \OutOfBoundsException(sprintf('Invalid date "%s"', $this->strDate)); } $this->strDate = mktime($intHour, (int) $intMinute, (int) $intSecond, (int) $intMonth, (int) $intDay, (int) $intYear); } /** * Convert a PHP format string into a JavaScript format string * * @param string $strFormat The PHP format string * * @return mixed The JavaScript format string */ public static function formatToJs($strFormat) { $chunks = str_split($strFormat); foreach ($chunks as $k=>$v) { switch ($v) { case 'D': $chunks[$k] = 'a'; break; case 'j': $chunks[$k] = 'e'; break; case 'l': $chunks[$k] = 'A'; break; case 'S': $chunks[$k] = 'o'; break; case 'F': $chunks[$k] = 'B'; break; case 'M': $chunks[$k] = 'b'; break; case 'a': $chunks[$k] = 'p'; break; case 'A': $chunks[$k] = 'p'; break; case 'g': $chunks[$k] = 'l'; break; case 'G': $chunks[$k] = 'k'; break; case 'h': $chunks[$k] = 'I'; break; case 'i': $chunks[$k] = 'M'; break; case 's': $chunks[$k] = 'S'; break; case 'U': $chunks[$k] = 's'; break; } } return preg_replace('/([a-zA-Z])/', '%$1', implode('', $chunks)); } /** * Check for a numeric date format * * @param string $strFormat The PHP format string * * @return boolean True if the date format is numeric */ public static function isNumericFormat($strFormat) { return !preg_match('/[BbCcDEeFfIJKkLlMNOoPpQqRrSTtUuVvWwXxZz]+/', $strFormat); } /** * Return the numeric date format string * * @return string The numeric date format string */ public static function getNumericDateFormat() { if (TL_MODE == 'FE') { /** @var PageModel $objPage */ global $objPage; if ($objPage->dateFormat && static::isNumericFormat($objPage->dateFormat)) { return $objPage->dateFormat; } } return Config::get('dateFormat'); } /** * Return the numeric time format string * * @return string The numeric time format string */ public static function getNumericTimeFormat() { if (TL_MODE == 'FE') { /** @var PageModel $objPage */ global $objPage; if ($objPage->timeFormat && static::isNumericFormat($objPage->timeFormat)) { return $objPage->timeFormat; } } return Config::get('timeFormat'); } /** * Return the numeric datim format string * * @return string The numeric datim format string */ public static function getNumericDatimFormat() { if (TL_MODE == 'FE') { /** @var PageModel $objPage */ global $objPage; if ($objPage->datimFormat && static::isNumericFormat($objPage->datimFormat)) { return $objPage->datimFormat; } } return Config::get('datimFormat'); } /** * Return a numeric format string depending on the regular expression name * * @param string $strRgxp The regular expression name * * @return string The numeric format string */ public static function getFormatFromRgxp($strRgxp) { switch ($strRgxp) { case 'date': return static::getNumericDateFormat(); case 'time': return static::getNumericTimeFormat(); case 'datim': return static::getNumericDatimFormat(); } return null; } /** * Parse a date format string and translate textual representations * * @param string $strFormat The date format string * @param integer $intTstamp An optional timestamp * * @return string The textual representation of the date */ public static function parse($strFormat, $intTstamp=null) { $strModified = str_replace ( array('l', 'D', 'F', 'M'), array('w::1', 'w::2', 'n::3', 'n::4'), $strFormat ); if ($intTstamp === null) { $strDate = date($strModified); } elseif (!is_numeric($intTstamp)) { return ''; } else { $strDate = date($strModified, $intTstamp); } $strReturn = static::resolveCustomModifiers($strDate); // HOOK: add custom logic (see #4260) if (isset($GLOBALS['TL_HOOKS']['parseDate']) && \is_array($GLOBALS['TL_HOOKS']['parseDate'])) { foreach ($GLOBALS['TL_HOOKS']['parseDate'] as $callback) { $strReturn = System::importStatic($callback[0])->{$callback[1]}($strReturn, $strFormat, $intTstamp); } } return $strReturn; } /** * Round a UNIX timestamp to the full minute * * @param integer $intTime The timestamp * * @return integer The rounded timestamp */ public static function floorToMinute($intTime=null) { if ($intTime === null) { $intTime = time(); } return $intTime - ($intTime % 60); } /** * Resolve the custom modifiers * * @param string $strDate The date string * * @return string The resolved date string */ protected static function resolveCustomModifiers($strDate) { if (strpos($strDate, '::') === false) { return $strDate; } System::loadLanguageFile('default'); if (!$GLOBALS['TL_LANG']['MSC']['dayShortLength']) { $GLOBALS['TL_LANG']['MSC']['dayShortLength'] = 3; } if (!$GLOBALS['TL_LANG']['MSC']['monthShortLength']) { $GLOBALS['TL_LANG']['MSC']['monthShortLength'] = 3; } $strReturn = ''; $chunks = preg_split("/([0-9]{1,2}::[1-4])/", $strDate, -1, PREG_SPLIT_DELIM_CAPTURE); foreach ($chunks as $chunk) { list($index, $flag) = explode('::', $chunk) + array(null, null); switch ($flag) { case 1: $strReturn .= $GLOBALS['TL_LANG']['DAYS'][$index]; break; case 2: $strReturn .= $GLOBALS['TL_LANG']['DAYS_SHORT'][$index]; break; case 3: $strReturn .= $GLOBALS['TL_LANG']['MONTHS'][($index - 1)]; break; case 4: $strReturn .= $GLOBALS['TL_LANG']['MONTHS_SHORT'][($index - 1)]; break; default: $strReturn .= $chunk; break; } } return $strReturn; } } class_alias(Date::class, 'Date'); An Error Occurred: Internal Server Error

Oops! An Error Occurred

The server returned a "500 Internal Server Error".

Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.