You are here

public function DateGranularity::addGranularity in Date 8

Adds a granularity entry to the array.

Parameters

string $part: A single date part.

1 call to DateGranularity::addGranularity()
DateGranularity::setGranularityFromTime in date_api/lib/Drupal/date_api/DateGranularity.php
Create a granularity array from a string time value.

File

date_api/lib/Drupal/date_api/DateGranularity.php, line 79
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 function addGranularity($part) {
  $this->granularity[] = $part;
  $this->granularity = array_unique($this->granularity);
}