public static function DateGranularity::hasGranularity in Date 8
Checks granularity array for a given entry.
@returns bool TRUE if the date part is present in the date's granularity.
Parameters
array|null $parts: An array of date parts. Defaults to NULL.
1 call to DateGranularity::hasGranularity()
- DateGranularity::validGranularity in date_api/
lib/ Drupal/ date_api/ DateGranularity.php - Determines if a date is valid for a given granularity.
File
- date_api/
lib/ Drupal/ date_api/ DateGranularity.php, line 165 - 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_apiCode
public static function hasGranularity($parts, $granularity) {
if (is_array($parts)) {
foreach ($parts as $part) {
if (!in_array($part, $granularity)) {
return FALSE;
}
}
return TRUE;
}
return in_array($parts, $granularity);
}