Interprets a date indicator string value as a date time string relative to the current date.

@param string $indicator
@return string
347384
protected function interpretDateIndicator($indicator)
    {
        if ( ! is_string($indicator)) {
            throw new \UnexpectedValueException('Unexpected date indicator value: ' . print_r($indicator, true));
        }

        if ('now' === strtolower($indicator)) {
            return Carbon::now()->format('Y-m-d H:i:s');
        }

        if (starts_with($indicator, '-')) {
            return Carbon::now()->sub(
                new \DateInterval(substr($indicator, 1))
            )->format('Y-m-d H:i:s');
        }
        if (starts_with($indicator, '+')) {
            return Carbon::now()->add(
                new \DateInterval(substr($indicator, 1))
            )->format('Y-m-d H:i:s');
        }

        return (new Carbon($indicator))->format('Y-m-d H:i:s');
    }
302165
public static function isFutureOrNow( $string )
	{
		$string	= Alg_TimeConverter::complementMonthDate( $string, 1 );
		$time	= strtotime( $string );
		if( $time === false )
			throw new InvalidArgumentException( 'Given Date "'.$string.'" could not been parsed.' );
		return $time > time();
	}
603809
public static function dateIntervalToIntervalSpec(DateInterval $di): string
    {
        $time_parts = ['h', 'i', 's', 'f'];
        $time_token_set = false;
        $interval_spec = 'P';

        foreach (array_keys(self::$tokens) as $token) {
            if (in_array($token, $time_parts) && $time_token_set === false && $di->$token > 0) {
                $interval_spec .= 'T';
                $time_token_set = true;
            }
            if ($di->$token > 0) {
                $token_string = $token;
                if (array_key_exists($token, self::$tokensSubstitution)) {
                    $token_string = self::$tokensSubstitution[$token];
                }
                $interval_spec .= $di->$token.strtoupper($token_string);
            }
        }

        return $interval_spec;
    }
340187
public function setValue($value)
	{
		if(is_numeric($value))
			$value = (int) $value;
		if(is_string($value))
			$value = strtotime($value);
		$value = date('Y/m/d', $value);
		$value = parent::setValue($value);
		return $value;
	}
1033198
public static function inPast($date, $time = null)
    {
        if (is_null($time)) {
            $time = self::time();
        }
        if (!is_int($date)) {
            $date = self::strtotime($date);
        }

        return $time > $date;
    }
843433
public function normalize($value)
    {
        if ($value) {
            if (is_int($value) || ctype_digit($value)) {
                $timestamp = $value;
            } elseif (!$timestamp = strtotime($value)) {
                return $value;
            }
            return date($this->_format, $timestamp);
        }
        return $value;
    }
722348
public function intlDateFormat($date)
    {
        if (($formatter = $this->getFormatter()) instanceof \IntlDateFormatter) {
            return $formatter->format($date);
        } elseif ($date instanceof \DateTime) {
            return $date->format('d-m-Y');
        }

        return date('d-m-Y', $date);
    }
244661
protected static function _getDateString($value)
    {
        $formatted = '';
        if (isset($value['year'], $value['month'], $value['day']) &&
            (is_numeric($value['year']) && is_numeric($value['month']) && is_numeric($value['day']))
        ) {
            $formatted .= sprintf('%d-%02d-%02d ', $value['year'], $value['month'], $value['day']);
        }

        if (isset($value['hour'])) {
            if (isset($value['meridian']) && (int)$value['hour'] === 12) {
                $value['hour'] = 0;
            }
            if (isset($value['meridian'])) {
                $value['hour'] = strtolower($value['meridian']) === 'am' ? $value['hour'] : $value['hour'] + 12;
            }
            $value += ['minute' => 0, 'second' => 0];
            if (is_numeric($value['hour']) && is_numeric($value['minute']) && is_numeric($value['second'])) {
                $formatted .= sprintf('%02d:%02d:%02d', $value['hour'], $value['minute'], $value['second']);
            }
        }

        return trim($formatted);
    }
18367
public function toString($value)
    {
        if ($value instanceof \DateTime) { // datetime in ISO8601 format
            return $value->format(\DateTime::ISO8601);
        } else if (is_bool($value)) {
            return $value ? 1 : 0;
        } else {
            return $value;
        }
    }
623209
public function dateString(string $time): string
    {
        return date($this->dateFormat, ctype_digit($time) ? $time : strtotime($time));
    }
1223044
static function longDateString($date) {
        str_replace('now', date('m.d.y'), $date);

        if (!self::parsable($date)) return null;

        $r = self::fromString($date);

        return $r->format('M d, Y');
    }
190873
public function getFormatsDate($prefix = true)
    {
        $formats = $this->formatsDate;
        // Add other common suggestions
        foreach ($this->formatInterval as $key => $value) {
            foreach (['hours', 'minutes', 'seconds'] as $exclusion) {
                if ($key == $exclusion) {
                    continue;
                }
            }
            foreach (['till', 'since'] as $op) {
                if ('age' == $key) {
                    $op = '';
                }
                $formats[$key.$op] = $value;
            }
        }

        return $this->prefixWithHelperName($formats, $prefix);
    }
471295
function getIndicator($ind)
    {
        if ($ind == 1) {
            return (string)$this->ind1;
        } elseif ($ind == 2) {
            return (string)$this->ind2;
        } else {
             $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_INDICATOR_REQUEST], array("indicator" => $indicator));
             throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_INVALID_INDICATOR_REQUEST);
        }
        return false;
    }
30515
public function currentDatetime()
    {
        if ($this->timeFormat === static::$timeFormatDatetime) {
            return date('Y-m-d H:i:s');
        }
        if ($this->timeFormat === static::$timeFormatTimestamp) {
            return time();
        }
        return null;
    }
788862
private function getDateAsString($res)
    {
        $dateTxt="";
        $environDateDebutTxt = "";
        if ($res['isDateDebutEnviron']=='1') {
            $environDateDebutTxt = "environ ";
        }

        switch (strtolower($res['nomTypeEvenement'])) {
            case 'information (nouveautés)':
            case 'extension':
            case 'inauguration':
            case 'exposition':
                $articleAvantTypeEvenement = "de l'";
                break;
            default:
                $articleAvantTypeEvenement = "de";
                break;
        }
        if (substr($res['dateDebut'], 5)=="00-00") {
            $datetime=substr($res['dateDebut'], 0, 4);
        } else {
            $datetime = $res['dateDebut'];
        }
        if ($res['nomTypeEvenement'] =='Construction') {
            if ($res['dateDebut']!='0000-00-00') {
                $dateTxt=_("Année de construction :")." <time itemprop='startDate' datetime='".$datetime."'>".$environDateDebutTxt.$this->date->toFrenchAffichage($res['dateDebut'])."</time>";
            }
            if ($res['dateFin']!='0000-00-00') {
                $dateTxt.=" (-> ".$this->date->toFrenchAffichage($res['dateFin']).")";
                $retourDateFin = " (-> ".$this->date->toFrenchAffichage($res['dateFin']).")";
            }
        } else {
            if ($res['dateDebut'] != '0000-00-00') {
                if ($res['MH'] != '1' && $res['ISMH'] != '1') {
                    if (pia_strlen($this->date->toFrench($res['dateDebut']))<=4) {
                        if (archiPersonne::isPerson($idEvenementGroupeAdresse)) {
                            $nomTypeEvenement = "début";
                        } else {
                            $nomTypeEvenement=strtolower($res['nomTypeEvenement']);
                        }
                        $dateTxt=_("Année")." ".$articleAvantTypeEvenement." <time itemprop='startDate' datetime='".$datetime."'>".$nomTypeEvenement." : $environDateDebutTxt".$this->date->toFrenchAffichage($res['dateDebut'])."</time>";
                    } else {
                        if (archiPersonne::isPerson($idEvenementGroupeAdresse)) {
                            $typeEvenement = "";
                        } else {
                            $typeEvenement=$articleAvantTypeEvenement." ".strtolower($res['nomTypeEvenement']);
                        }
                        $dateTxt=_("Date")." <time itemprop='startDate' datetime='".$datetime."'>".$typeEvenement." : $environDateDebutTxt".$this->date->toFrenchAffichage($res['dateDebut'])."</time>";
                    }
                }
                if ($res['MH']=='1') {
                    $dateTxt= "<b>"._("Classement Monument Historique")."</b> $environDateDebutTxt le ".$this->date->toFrenchAffichage($res['dateDebut']);
                    $isMH=true;
                }

                if ($res['ISMH'] == '1') {
                    $dateTxt = "<b>"._("Inscription à l'Inventaire Supplémentaire des Monuments Historiques")."</b> $environDateDebutTxt : ".$this->date->toFrenchAffichage($res['dateDebut']);
                    if ($res['MH'] =='1') {
                        $dateTxt.="<br><b>"._("Classement Monument Historique")."</b> $environDateDebutTxt : ".$this->date->toFrenchAffichage($res['dateDebut']);
                    }
                    $isISMH=true;
                }
            }

            if ($res['dateFin'] != '0000-00-00') {
                if (pia_strlen($this->date->toFrench($res['dateFin']))<=4) {
                    $dateTxt.=" "._("à")." ".$this->date->toFrenchAffichage($res['dateFin']);
                } else {
                    $dateTxt.=" "._("au")." ".$this->date->toFrenchAffichage($res['dateFin']);
                }
            }
        }
        return $dateTxt;
    }
1092700
protected function getDateTime($value)
    {
        try {
            if ($this->isTestingRelativeDateTime($value)) {
                return Date::parse($value);
            }

            return new DateTime($value);
        } catch (Exception $e) {
            //
        }
    }
928273
public function nicetimeFunc($date, $long_strings = true, $show_tense = true)
    {
        if (empty($date)) {
            return $this->grav['language']->translate('GRAV.NICETIME.NO_DATE_PROVIDED', null, true);
        }

        if ($long_strings) {
            $periods = [
                'NICETIME.SECOND',
                'NICETIME.MINUTE',
                'NICETIME.HOUR',
                'NICETIME.DAY',
                'NICETIME.WEEK',
                'NICETIME.MONTH',
                'NICETIME.YEAR',
                'NICETIME.DECADE'
            ];
        } else {
            $periods = [
                'NICETIME.SEC',
                'NICETIME.MIN',
                'NICETIME.HR',
                'NICETIME.DAY',
                'NICETIME.WK',
                'NICETIME.MO',
                'NICETIME.YR',
                'NICETIME.DEC'
            ];
        }

        $lengths = ['60', '60', '24', '7', '4.35', '12', '10'];

        $now = time();

        // check if unix timestamp
        if ((string)(int)$date === (string)$date) {
            $unix_date = $date;
        } else {
            $unix_date = strtotime($date);
        }

        // check validity of date
        if (empty($unix_date)) {
            return $this->grav['language']->translate('GRAV.NICETIME.BAD_DATE', null, true);
        }

        // is it future date or past date
        if ($now > $unix_date) {
            $difference = $now - $unix_date;
            $tense      = $this->grav['language']->translate('GRAV.NICETIME.AGO', null, true);

        } elseif ($now == $unix_date) {
            $difference = $now - $unix_date;
            $tense      = $this->grav['language']->translate('GRAV.NICETIME.JUST_NOW', null, false);

        } else {
            $difference = $unix_date - $now;
            $tense      = $this->grav['language']->translate('GRAV.NICETIME.FROM_NOW', null, true);
        }

        for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths) - 1; $j++) {
            $difference /= $lengths[$j];
        }

        $difference = round($difference);

        if ($difference != 1) {
            $periods[$j] .= '_PLURAL';
        }

        if ($this->grav['language']->getTranslation($this->grav['language']->getLanguage(),
            $periods[$j] . '_MORE_THAN_TWO')
        ) {
            if ($difference > 2) {
                $periods[$j] .= '_MORE_THAN_TWO';
            }
        }

        $periods[$j] = $this->grav['language']->translate('GRAV.'.$periods[$j], null, true);

        if ($now == $unix_date) {
            return $tense;
        }

        $time = "{$difference} {$periods[$j]}";
        $time .= $show_tense ? " {$tense}" : '';

        return $time;
    }