You are here

function _get_custom_date_format in Date 7.2

Same name and namespace in other branches
  1. 7.3 date.module \_get_custom_date_format()

Get a custom date format.

1 call to _get_custom_date_format()
date_formatter_process in ./date.module
Helper function for creating formatted date arrays from a formatter.

File

./date.module, line 321

Code

function _get_custom_date_format($date, $format) {
  $custom = array();
  $custom['granularities'] = array(
    'date' => array(
      'year',
      'month',
      'day',
    ),
    'time' => array(
      'hour',
      'minute',
      'second',
    ),
    'zone' => array(
      'timezone',
    ),
  );
  $custom['limits'] = array(
    'date' => date_limit_format($format, $custom['granularities']['date']),
    'time' => date_limit_format($format, $custom['granularities']['time']),
    'zone' => date_limit_format($format, $custom['granularities']['zone']),
  );
  return array(
    'formatted' => date_format_date($date, 'custom', $format),
    'date' => date_format_date($date, 'custom', $custom['limits']['date']),
    'time' => date_format_date($date, 'custom', $custom['limits']['time']),
    'zone' => date_format_date($date, 'custom', $custom['limits']['zone']),
  );
}