You are here

views_date_format_sql.module in Views Date Format SQL 7.3

Same filename and directory in other branches
  1. 8.3 views_date_format_sql.module

File

views_date_format_sql.module
View source
<?php

/**
 * Implements hook_views_api().
 */
function views_date_format_sql_views_api() {
  return array(
    'api' => 3,
  );
}

/**
 * Helper to retrieve the format to a given date format name.
 * see includes/common.inc:function format_date()
 */
function _views_date_format_sql_get_date_format($type = 'medium', $format = '') {
  switch ($type) {
    case 'short':
      $format = variable_get('date_format_short', 'm/d/Y - H:i');
      break;
    case 'long':
      $format = variable_get('date_format_long', 'l, F j, Y - H:i');
      break;
    case 'custom':

      // No change to format.
      break;
    case 'medium':
    default:

      // Retrieve the format of the custom $type passed.
      if ($type != 'medium') {
        $format = variable_get('date_format_' . $type, '');
      }

      // Fall back to 'medium'.
      if ($format === '') {
        $format = variable_get('date_format_medium', 'D, m/d/Y - H:i');
      }
      break;
  }
  return $format;
}

Functions

Namesort descending Description
views_date_format_sql_views_api Implements hook_views_api().
_views_date_format_sql_get_date_format Helper to retrieve the format to a given date format name. see includes/common.inc:function format_date()