1 date.inc | date_format_patterns($strict = FALSE) |
Constructs an array of regex replacement strings for date format elements.
Parameters
bool $strict: Whether or not to force 2 digits for elements that sometimes allow either 1 or 2 digits.
Return value
array: An array of date() format letters and their regex equivalents.
File
- core/
includes/ date.inc, line 412 - Date API functions.
Code
function date_format_patterns($strict = FALSE) {
return array(
'd' => '\d{' . ($strict ? '2' : '1,2') . '}',
'm' => '\d{' . ($strict ? '2' : '1,2') . '}',
'h' => '\d{' . ($strict ? '2' : '1,2') . '}',
'H' => '\d{' . ($strict ? '2' : '1,2') . '}',
'i' => '\d{' . ($strict ? '2' : '1,2') . '}',
's' => '\d{' . ($strict ? '2' : '1,2') . '}',
'j' => '\d{1,2}',
'N' => '\d',
'S' => '\w{2}',
'w' => '\d',
'W' => '\d{1,2}',
'n' => '\d{1,2}',
't' => '\d{2}',
'L' => '\d',
'o' => '\d{4}',
'Y' => '-?\d{1,6}',
'y' => '\d{2}',
'B' => '\d{3}',
'g' => '\d{1,2}',
'G' => '\d{1,2}',
'e' => '\w*',
'I' => '\d',
'T' => '\w*',
'U' => '\d*',
'z' => '[+-]?\d*',
// Using S instead of w and 3 as well as 4 to pick up non-ASCII chars like
// German umlaut. Per http://drupal.org/node/1101284, we may need as little
// as 2 and as many as 5 characters in some languages.
'D' => '\S{2,5}',
'l' => '\S*',
'M' => '\S{2,5}',
'F' => '\S*',
'P' => '[+-]?\d{2}\:\d{2}',
'O' => '[+-]\d{4}',
'c' => '(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})([+-]?\d{2}\:\d{2})',
'r' => '(\w{3}), (\d{2})\s(\w{3})\s(\d{2,4})\s(\d{2}):(\d{2}):(\d{2})([+-]?\d{4})?',
);
}