public function CarbonInterval::spec in Persian Date for Drupal 8 8.4
Get the interval_spec string
Return value
string
File
- src/
Library/ Carbon/ CarbonInterval.php, line 532
Class
- CarbonInterval
- A simple API extension for DateInterval. The implementation provides helpers to handle weeks but only days are saved. Weeks are calculated based on the total days of the current instance.
Namespace
Drupal\persian_date\Library\CarbonCode
public function spec() {
$date = array_filter(array(
static::PERIOD_YEARS => $this->y,
static::PERIOD_MONTHS => $this->m,
static::PERIOD_DAYS => $this->d,
));
$time = array_filter(array(
static::PERIOD_HOURS => $this->h,
static::PERIOD_MINUTES => $this->i,
static::PERIOD_SECONDS => $this->s,
));
$specString = static::PERIOD_PREFIX;
foreach ($date as $key => $value) {
$specString .= $value . $key;
}
if (count($time) > 0) {
$specString .= static::PERIOD_TIME_PREFIX;
foreach ($time as $key => $value) {
$specString .= $value . $key;
}
}
return $specString === static::PERIOD_PREFIX ? 'PT0S' : $specString;
}