function date_format_patterns in Date 7.2
Same name and namespace in other branches
- 5.2 date_api.module \date_format_patterns()
- 6.2 date_api.module \date_format_patterns()
- 6 date_api.module \date_format_patterns()
- 7.3 date_api/date_api.module \date_format_patterns()
- 7 date_api/date_api.module \date_format_patterns()
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.
1 call to date_format_patterns()
- DateObject::parse in date_api/
date_api.module - Converts a date string into a date object.
File
- date_api/
date_api.module, line 1540 - This module will make the date API available to other modules.
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',
'z' => '\\d{1,3}',
'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*',
'O' => '[+-]?\\d{4}',
// 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})?',
);
}