function date_granularity_array_from_precision in Date 7
Same name and namespace in other branches
- 6.2 date_api.module \date_granularity_array_from_precision()
- 7.3 date_api/date_api.module \date_granularity_array_from_precision()
- 7.2 date_api/date_api.module \date_granularity_array_from_precision()
Give a granularity $precision, return an array of all the possible granularity elements.
File
- date_api/
date_api.module, line 1052 - 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_granularity_array_from_precision($precision) {
$granularity_array = array(
'year',
'month',
'day',
'hour',
'minute',
'second',
);
switch ($precision) {
case 'year':
return array_slice($granularity_array, -6);
case 'month':
return array_slice($granularity_array, -5);
case 'day':
return array_slice($granularity_array, -4);
case 'hour':
return array_slice($granularity_array, -3);
case 'minute':
return array_slice($granularity_array, -2);
default:
return $granularity_array;
}
}