You are here

function facetapi_timestamp_format in Facet API 6

Returns a formatted date based on the passed timestamp and gap.

This function assumes that gaps less than one day will be displayed in a search context in which a larger containing gap including a day is already displayed. So, HOUR, MINUTE, and SECOND gaps only display time information, without date.

Parameters

$timestamp: An integer containing the Unix timestamp.

$gap: A string containing the gap, see FACETAPI_DATE_* constants for valid values, defaults to YEAR.

Return value

A gap-appropriate display date used in the facet link.

1 call to facetapi_timestamp_format()
facetapi_date_format in ./facetapi.module
Returns a formatted date based on the passed ISO date string and gap.

File

./facetapi.module, line 1212
An abstracted facet API that can be used by various search backens.

Code

function facetapi_timestamp_format($timestamp, $gap = FACETAPI_DATE_YEAR) {
  switch ($gap) {
    case FACETAPI_DATE_MONTH:
      return format_date($timestamp, 'custom', 'F Y', 0);
    case FACETAPI_DATE_DAY:
      return format_date($timestamp, 'custom', 'F j, Y', 0);
    case FACETAPI_DATE_HOUR:
      return format_date($timestamp, 'custom', 'g A', 0);
    case FACETAPI_DATE_MINUTE:
      return format_date($timestamp, 'custom', 'g:i A', 0);
    case FACETAPI_DATE_SECOND:
      return format_date($timestamp, 'custom', 'g:i:s A', 0);
    default:
      return format_date($timestamp, 'custom', 'Y', 0);
  }
}