You are here

function date_sql_handler::views_formats in Date 6

Same name and namespace in other branches
  1. 5.2 date_api_sql.inc \date_sql_handler::views_formats()
  2. 6.2 date_api_sql.inc \date_sql_handler::views_formats()
  3. 7.3 date_api/date_api_sql.inc \date_sql_handler::views_formats()
  4. 7 date_api/date_api_sql.inc \date_sql_handler::views_formats()
  5. 7.2 date_api/date_api_sql.inc \date_sql_handler::views_formats()

File

./date_api_sql.inc, line 570

Class

date_sql_handler
A class to manipulate date SQL.

Code

function views_formats($granularity, $type = 'sql') {
  $formats = array(
    'display',
    'sql',
  );
  switch ($granularity) {
    case 'year':
      $formats['display'] = 'Y';
      $formats['sql'] = 'Y';
      break;
    case 'month':
      $formats['display'] = 'F Y';
      $formats['sql'] = 'Y-m';
      break;
    case 'day':
      $formats['display'] = 'F j Y';
      $formats['sql'] = 'Y-m-d';
      break;
    case 'hour':
      $formats['display'] = 'F j Y - H';
      $formats['sql'] = 'Y-m-d\\TH';
      break;
    case 'week':
      $formats['display'] = 'F j Y (W)';
      $formats['sql'] = 'Y-\\WW';
      break;
  }
  return $formats[$type];
}