function date_sql_handler::views_formats in Date 6.2
Same name and namespace in other branches
- 5.2 date_api_sql.inc \date_sql_handler::views_formats()
- 6 date_api_sql.inc \date_sql_handler::views_formats()
- 7.3 date_api/date_api_sql.inc \date_sql_handler::views_formats()
- 7 date_api/date_api_sql.inc \date_sql_handler::views_formats()
- 7.2 date_api/date_api_sql.inc \date_sql_handler::views_formats()
File
- ./
date_api_sql.inc, line 649 - SQL date functions.
Class
- date_sql_handler
- A class to manipulate date SQL.
Code
function views_formats($granularity, $type = 'sql') {
$formats = array(
'display',
'sql',
);
// Start with the site long date format and add seconds to it
$long = str_replace(':i', ':i:s', variable_get('date_format_long', 'l, F j, Y - H:i'));
switch ($granularity) {
case 'year':
$formats['display'] = 'Y';
$formats['sql'] = 'Y';
break;
case 'month':
$formats['display'] = date_limit_format($long, array(
'year',
'month',
));
$formats['sql'] = 'Y-m';
break;
case 'day':
$formats['display'] = date_limit_format($long, array(
'year',
'month',
'day',
));
$formats['sql'] = 'Y-m-d';
break;
case 'hour':
$formats['display'] = date_limit_format($long, array(
'year',
'month',
'day',
'hour',
));
$formats['sql'] = 'Y-m-d\\TH';
break;
case 'minute':
$formats['display'] = date_limit_format($long, array(
'year',
'month',
'day',
'hour',
'minute',
));
$formats['sql'] = 'Y-m-d\\TH:i';
break;
case 'second':
$formats['display'] = date_limit_format($long, array(
'year',
'month',
'day',
'hour',
'minute',
'second',
));
$formats['sql'] = 'Y-m-d\\TH:i:s';
break;
case 'week':
$formats['display'] = 'F j Y (W)';
$formats['sql'] = 'Y-\\WW';
break;
}
return $formats[$type];
}