544 $this->day_pcre =
'(' . implode(array_keys($this->day),
'|') .
')';
545 $this->month_pcre =
'(' . implode(array_keys($this->month),
'|') .
')';
548 if (!isset($cache[get_class($this)]))
550 $all_methods = get_class_methods($this);
552 foreach ($all_methods as $method)
554 if (strtolower(substr($method, 0, 5)) ===
'date_')
556 $cache[get_class($this)][] = $method;
561 foreach ($cache[get_class($this)] as $method)
563 $this->built_in[] = $method;
572 public static function get()
592 foreach ($this->user as $method)
594 if (($returned = call_user_func($method,
$date)) !==
false)
600 foreach ($this->built_in as $method)
602 if (($returned = call_user_func(array($this, $method),
$date)) !==
false)
620 if (is_callable($callback))
622 $this->user[] = $callback;
626 trigger_error(
'User-supplied function must be a valid callback', E_USER_WARNING);
643 $year =
'([0-9]{4})';
644 $month =
$day = $hour = $minute = $second =
'([0-9]{2})';
645 $decimal =
'([0-9]*)';
646 $zone =
'(?:(Z)|([+\-])([0-9]{1,2}):?([0-9]{1,2}))';
647 $pcre =
'/^' . $year .
'(?:-?' .
$month .
'(?:-?' .
$day .
'(?:[Tt\x09\x20]+' . $hour .
'(?::?' . $minute .
'(?::?' . $second .
'(?:.' . $decimal .
')?)?)?' . $zone .
')?)?)?$/';
649 if (preg_match($pcre,
$date, $match))
667 for ($i = count($match); $i <= 3; $i++)
672 for ($i = count($match); $i <= 7; $i++)
678 if (isset($match[9]) && $match[9] !==
'')
682 if ($match[9] ===
'-')
693 $second = round($match[6] + $match[7] / pow(10, strlen($match[7])));
695 return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) -
$timezone;
712 $string = (string) $string;
714 $length = strlen($string);
719 while ($position < $length && ($pos = strpos($string,
'(', $position)) !==
false)
721 $output .= substr($string, $position, $pos - $position);
722 $position = $pos + 1;
723 if ($string[$pos - 1] !==
'\\')
726 while ($depth && $position < $length)
728 $position += strcspn($string,
'()', $position);
729 if ($string[$position - 1] ===
'\\')
734 elseif (isset($string[$position]))
736 switch ($string[$position])
759 $output .= substr($string, $position);
776 $fws =
'(?:' . $wsp .
'+|' . $wsp .
'*(?:\x0D\x0A' . $wsp .
'+)+)';
777 $optional_fws = $fws .
'?';
780 $day =
'([0-9]{1,2})';
781 $hour = $minute = $second =
'([0-9]{2})';
782 $year =
'([0-9]{2,4})';
783 $num_zone =
'([+\-])([0-9]{2})([0-9]{2})';
784 $character_zone =
'([A-Z]{1,5})';
785 $zone =
'(?:' . $num_zone .
'|' . $character_zone .
')';
786 $pcre =
'/(?:' . $optional_fws . $day_name . $optional_fws .
',)?' . $optional_fws .
$day . $fws .
$month . $fws . $year . $fws . $hour . $optional_fws .
':' . $optional_fws . $minute .
'(?:' . $optional_fws .
':' . $optional_fws . $second .
')?' . $fws . $zone .
'/i';
806 $month = $this->month[strtolower($match[3])];
809 if ($match[8] !==
'')
813 if ($match[8] ===
'-')
819 elseif (isset($this->timezone[strtoupper($match[11])]))
821 $timezone = $this->timezone[strtoupper($match[11])];
834 elseif ($match[4] < 1000)
840 if ($match[7] !==
'')
849 return gmmktime($match[5], $match[6], $second,
$month, $match[2], $match[4]) -
$timezone;
868 $space =
'[\x09\x20]+';
871 $day =
'([0-9]{1,2})';
872 $year = $hour = $minute = $second =
'([0-9]{2})';
873 $zone =
'([A-Z]{1,5})';
874 $pcre =
'/^' . $day_name .
',' . $space .
$day .
'-' .
$month .
'-' . $year . $space . $hour .
':' . $minute .
':' . $second . $space . $zone .
'$/i';
876 if (preg_match($pcre,
$date, $match))
891 $month = $this->month[strtolower($match[3])];
894 if (isset($this->timezone[strtoupper($match[8])]))
896 $timezone = $this->timezone[strtoupper($match[8])];
914 return gmmktime($match[5], $match[6], $match[7],
$month, $match[2], $match[4]) -
$timezone;
933 $space =
'[\x09\x20]+';
936 $day =
'([0-9]{1,2})';
937 $hour = $sec = $min =
'([0-9]{2})';
938 $year =
'([0-9]{4})';
939 $terminator =
'\x0A?\x00?';
940 $pcre =
'/^' . $wday_name . $space . $mon_name . $space .
$day . $space . $hour .
':' . $min .
':' . $sec . $space . $year . $terminator .
'$/i';
942 if (preg_match($pcre,
$date, $match))
955 $month = $this->month[strtolower($match[2])];
956 return gmmktime($match[4], $match[5], $match[6],
$month, $match[3], $match[7]);
972 $strtotime = strtotime(
$date);
973 if ($strtotime === -1 || $strtotime ===
false)