public static function Carbon::hasRelativeKeywords in Persian Date for Drupal 8 8.4
Determine if there is a relative keyword in the time string, this is to create dates relative to now for test instances. e.g.: next tuesday
Parameters
string $time:
Return value
bool true if there is a keyword, otherwise false
1 call to Carbon::hasRelativeKeywords()
- Carbon::__construct in src/
Library/ Carbon/ Carbon.php - Create a new Carbon instance.
File
- src/
Library/ Carbon/ Carbon.php, line 1079
Class
- Carbon
- A simple API extension for DateTime
Namespace
Drupal\persian_date\Library\CarbonCode
public static function hasRelativeKeywords($time) {
// skip common format with a '-' in it
if (preg_match('/\\d{4}-\\d{1,2}-\\d{1,2}/', $time) !== 1) {
foreach (static::$relativeKeywords as $keyword) {
if (stripos($time, $keyword) !== false) {
return true;
}
}
}
return false;
}