function date_format_order in Date 6
Same name and namespace in other branches
- 8 date_api/date_api.module \date_format_order()
- 5.2 date_api.module \date_format_order()
- 6.2 date_api.module \date_format_order()
- 7.3 date_api/date_api.module \date_format_order()
- 7 date_api/date_api.module \date_format_order()
- 7.2 date_api/date_api.module \date_format_order()
Convert a format to an ordered array of granularity parts.
Example: date_format_order('m/d/Y H:i') returns array( 0 => 'month', 1 => 'day', 2 => 'year', 3 => 'hour', 4 => 'minute', );
Parameters
string $format:
Return value
array of ordered granularity elements in this format string
6 calls to date_format_order()
- date_parts_element in ./
date_api_elements.inc - Create form elements for one or more date parts.
- date_popup_input_value in date_popup/
date_popup.module - Helper function for extracting a date value out of user input.
- date_popup_process_date in date_popup/
date_popup.module - Process the date portion of the element.
- date_popup_process_time in date_popup/
date_popup.module - Process the time portion of the element.
- date_select_process in ./
date_api_elements.inc - Flexible date/time drop-down selector.
File
- ./
date_api.module, line 1256 - 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_order($format) {
$order = array();
if (empty($format)) {
return $order;
}
$max = strlen($format);
for ($i = 0; $i <= $max; $i++) {
if (!isset($format[$i])) {
break;
}
$c = $format[$i];
switch ($c) {
case 'd':
case 'j':
$order[] = 'day';
break;
case 'F':
case 'M':
case 'm':
case 'n':
$order[] = 'month';
break;
case 'Y':
case 'y':
$order[] = 'year';
break;
case 'g':
case 'G':
case 'h':
case 'H':
$order[] = 'hour';
break;
case 'i':
$order[] = 'minute';
break;
case 's':
$order[] = 'second';
break;
}
}
return $order;
}