You are here

public static function DateGranularity::granularityNames in Date 8

Constructs an array of granularity options and their labels.

Return value

array An array of translated date parts, keyed by their machine name.

6 calls to DateGranularity::granularityNames()
DateFieldListWidget::settingsForm in date_field/lib/Drupal/date_field/Plugin/field/widget/DateFieldListWidget.php
Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::settingsForm().
DateTextWidget::settingsForm in lib/Drupal/date/Plugin/field/widget/DateTextWidget.php
Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::settingsForm().
date_field_field_settings_form in date_field/date_field.module
Helper function for date_field_settings_form().
date_tools_wizard_form in date_tools/date_tools.wizard.inc
@todo.
theme_date_text_parts in ./date.theme
Returns HTML for the text/select options for date parts in a table.

... See full list

File

date_api/lib/Drupal/date_api/DateGranularity.php, line 61
Definition of DateGranularity.

Class

DateGranularity
This class manages granularity. It can set granularity, get it from an array, get it from a format string, see if the array has any time or date elements, set and unset various granularity parts, create a nongranularity array of the granularity parts…

Namespace

Drupal\date_api

Code

public static function granularityNames() {
  return array(
    'year' => t('Year', array(), array(
      'context' => 'datetime',
    )),
    'month' => t('Month', array(), array(
      'context' => 'datetime',
    )),
    'day' => t('Day', array(), array(
      'context' => 'datetime',
    )),
    'hour' => t('Hour', array(), array(
      'context' => 'datetime',
    )),
    'minute' => t('Minute', array(), array(
      'context' => 'datetime',
    )),
    'second' => t('Second', array(), array(
      'context' => 'datetime',
    )),
  );
}