You are here

function date_format_patterns in Date 6

Same name and namespace in other branches
  1. 5.2 date_api.module \date_format_patterns()
  2. 6.2 date_api.module \date_format_patterns()
  3. 7.3 date_api/date_api.module \date_format_patterns()
  4. 7 date_api/date_api.module \date_format_patterns()
  5. 7.2 date_api/date_api.module \date_format_patterns()

Array of regex replacement strings for date format elements. Used to allow input in custom formats. Based on work done for the Date module by Yves Chedemois (yched).

Return value

array of date() format letters and their regex equivalents.

1 call to date_format_patterns()
date_convert_from_custom in ./date_api_elements.inc
Convert a date input in a custom format to a standard date type

File

./date_api.module, line 362
This module will make the date API available to other modules. Designed to provide a light but flexible assortment of functions and constants, with more functionality in additional files that are not loaded unless other modules specifically include them.

Code

function date_format_patterns() {
  return array(
    'd' => '\\d{2}',
    'j' => '\\d{1,2}',
    'N' => '\\d',
    'S' => '\\w{2}',
    'w' => '\\d',
    'z' => '\\d{1,3}',
    'W' => '\\d{1,2}',
    'm' => '\\d{2}',
    'n' => '\\d{1,2}',
    't' => '\\d{2}',
    'L' => '\\d',
    'o' => '\\d{4}',
    'Y' => '\\d{4}',
    'y' => '\\d{2}',
    'B' => '\\d{3}',
    'g' => '\\d{1,2}',
    'G' => '\\d{1,2}',
    'h' => '\\d{2}',
    'H' => '\\d{2}',
    'i' => '\\d{2}',
    's' => '\\d{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 umlaute
    'D' => '\\S{3,4}',
    'l' => '\\S*',
    'M' => '\\S{3,4}',
    'F' => '\\S*',
    'P' => '[+-]?\\d{2}\\:\\d{2}',
    '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})?',
  );
}