You are here

public function DateObject::limitGranularity in Date 7.2

Same name and namespace in other branches
  1. 7.3 date_api/date_api.module \DateObject::limitGranularity()
  2. 7 date_api/date_api.module \DateObject::limitGranularity()

Removes unwanted date parts from a date.

In common usage we should not unset timezone through this.

Parameters

array $granularity: An array of date parts.

File

date_api/date_api.module, line 556
This module will make the date API available to other modules.

Class

DateObject
Extend PHP DateTime class.

Code

public function limitGranularity(array $granularity) {
  foreach ($this->granularity as $key => $val) {
    if ($val != 'timezone' && !in_array($val, $granularity)) {
      unset($this->granularity[$key]);
    }
  }
}