You are here

public function DateGranularity::__construct in Date 8

Constructor. Create a granularity instance.

Parameters

mixed $input: A granularity array.

File

date_api/lib/Drupal/date_api/DateGranularity.php, line 42
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 __construct($input = NULL, $type = 'array') {
  switch ($type) {
    case 'time':
      $this
        ->setGranularityFromTime($input);
      break;
    case 'format':
      $this
        ->setGranularityFromFormat($input);
      break;
    default:
      $this
        ->setGranularityFromArray($input);
  }
}