Format date to human readable when date is today

@param object $parsedTxt Texts returned by humanReadable method
@param \DateInterval $diff Interval between now and date to read

@return void
763704
protected function humanDateToday($parsedTxt, \DateInterval $diff)
    {
        $textKey = 'today_past';
        if ($diff->invert === 1) {
            $textKey = 'today_future';
        }
        
        $time = '';
        if ($diff->h === 0 && $diff->i === 0) {
            $time .= $diff->s.'s';
        } elseif ($diff->h === 0) {
            $time .= $diff->i.'min';
        } else {
            $time .= $diff->h.'h';
        }
        
        $currentClass    = get_called_class();
        $parsedTxt->date = $currentClass::$humanReadableI18n[$textKey];
        
        $this->humanParseDateAndTimeText($parsedTxt, '', $time);
    }
1210575
public function readEdiSegmentDTM($PeriodQualifier)
    {
        $date = $this->readEdiDataValue(['DTM', ['1.0' => $PeriodQualifier]], 1, 1);
        $format = $this->readEdiDataValue(['DTM', ['1.0' => $PeriodQualifier]], 1, 2);
        if (empty($date)) {
            return $date;
        }
        switch ($format) {

            case 203: //CCYYMMDDHHMM
                return \preg_replace('#(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)#', '$1-$2-$3 $4:$5:00', $date);

            case 102: //CCYYMMDD
                return \preg_replace('/(\d{4})(\d{2})(\d{2})/', '$1-$2-$3', $date);

            default:
                return $date;
        }
    }
1054446
protected Object doParseValue(String formattedString, Class targetClass) throws ParseException {
		return dateFormat.parse(formattedString);
	}
71814
def process_date_updated(self, text):
        """"""
        date = parse(text)
        if self.date_updated == 'N/A':
            self.date_updated = date
        if date > self.date_updated:
            self.date_updated = date
1101729
public static function toSecondsUsingDays(\DateInterval $interval)
    {
        $seconds = (string) $interval->s;

        if ($interval->i) {
            $seconds = bcadd($seconds, bcmul($interval->i, self::SECONDS_MINUTE));
        }

        if ($interval->h) {
            $seconds = bcadd($seconds, bcmul($interval->h, self::SECONDS_HOUR));
        }

        if ((false !== $interval->days) && (0 <= $interval->days)) {
            $seconds = bcadd($seconds, bcmul($interval->days, self::SECONDS_DAY));
        } else {
            throw new InvalidArgumentException(
                'The "days" property is not set.'
            );
        }

        return $seconds;
    }
1127999
function(file, t) {
		var self = this, 
			ts   = t || file.ts, 
			i18  = self.i18,
			date, format, output, d, dw, m, y, h, g, i, s;

		if (self.options.clientFormatDate && ts > 0) {

			date = new Date(ts*1000);
			format = ts >= this.yesterday 
				? this.fancyFormat 
				: this.dateFormat;

			output = self.date(format, date);
			
			return ts >= this.yesterday
				? output.replace('$1', this.i18n(ts >= this.today ? 'Today' : 'Yesterday'))
				: output;
		} else if (file.date) {
			return file.date.replace(/([a-z]+)\s/i, function(a1, a2) { return self.i18n(a2)+' '; });
		}
		
		return self.i18n('dateUnknown');
	}
97188
protected function resolveFormat(\DateInterval $interval): string
    {
        $baseFormat = $this->resolveBaseFormat($interval);
        $timeFormat = $this->resolveTimeFormat($interval);

        if ($baseFormat === '') {
            if ($timeFormat === '') {
                return '';
            }

            return 'PT' . $timeFormat;
        }

        if ($timeFormat === '') {
            return 'P' . $baseFormat;
        }

        return 'P' . $baseFormat . 'T' . $timeFormat;
    }
402953
public function parseText() : void
    {
        if (!count($this->stream->getTokens())) {
            return;
        }

        if ($this->accept(Token::T_TEXT)) {
            $this->insert(new TextNode($this->getCurrentToken()->getValue()));
            $this->advance();
        }
    }
593316
public static function formatted_timeframe($startStr, $endStr)
    {
        $str = null;

        if ($startStr == $endStr) {
            return null;
        }

        $startTime = strtotime($startStr->value);
        $endTime = strtotime($endStr->value);

        if ($startTime == $endTime) {
            return null;
        }

        if ($endStr) {
            //time frame is only applicable if both start and end time is on the same day
            if (date('Y-m-d', $startTime) == date('Y-m-d', $endTime)) {
                $str = date('g:ia', $startTime) . ' - ' . date('g:ia', $endTime);
            }
        } else {
            $str = date('g:ia', $startTime);
        }

        return $str;
    }
27747
public function formatInterval(\DateInterval $dateInterval): string
    {
        $format = 'P';

        if (0 < $dateInterval->y) {
            $format .= $dateInterval->y.'Y';
        }

        if (0 < $dateInterval->m) {
            $format .= $dateInterval->m.'M';
        }

        if (0 < $dateInterval->d) {
            $format .= $dateInterval->d.'D';
        }

        if (0 < $dateInterval->h || 0 < $dateInterval->i || 0 < $dateInterval->s) {
            $format .= 'T';
        }

        if (0 < $dateInterval->h) {
            $format .= $dateInterval->h.'H';
        }

        if (0 < $dateInterval->i) {
            $format .= $dateInterval->i.'M';
        }

        if (0 < $dateInterval->s) {
            $format .= $dateInterval->s.'S';
        }

        return $format;
    }
663405
final public static function formatDateDiff($start, $end = null, $parts = 0)
    {
        if (!($start instanceof \DateTimeInterface)) {
            $start = self::asDateTime($start);
        }

        if ($end === null) {
            $end = self::now();
        } else {
            if (!($end instanceof \DateTimeInterface)) {
                $end = self::asDateTime($end);
            }
        }

        $interval = $end->diff($start);

        return self::formatInterval($interval, $parts);
    }
359318
private function calculate($units, DateInterval $diff)
    {
        $calculator = [
            'centuries' => function (DateInterval $diff) {
                return $diff->y / 100;
            },
            'decades' => function (DateInterval $diff) {
                return $diff->y / 10;
            },
            'years' => function (DateInterval $diff) {
                return $diff->y;
            },
            'months' => function (DateInterval $diff) {
                return $diff->y * 12 + $diff->m;
            },
            'days' => function (DateInterval $diff) {
                return $diff->days;
            },
            'hours' => function (DateInterval $diff) {
                return ($diff->days * 24) + $diff->h;
            },
            'minutes' => function (DateInterval $diff) {
                return ($diff->days * 24 * 60) + $diff->i;
            },
            'seconds' => function (DateInterval $diff) {
                return ($diff->days * 24 * 60 * 60) + $diff->s;
            },
        ];
        $u = isset($calculator[$units]) ? $units : 'years';

        return $calculator[$u]($diff);
    }
1228627
private function getDate($parsed_info, $type)
    {
        $date = explode('-', $parsed_info[1]);
        if ($type == 'start') {
            return trim($date[0]);
        } else {
            return trim($date[1]);
        }
    }
328223
private function parseDate($text)
    {
        if (empty($text) || '-' == $text) {
            return null;
        }

        $date = \DateTime::createFromFormat('d/m/Y', $text);

        return false === $date ? null : $date->format('Y-m-d').'T00:00:00.000Z';
    }
559101
protected function formatDatetime($timestamp = 0, $format = '')
    {
        switch ($this->timeset) {
            case 1:
                // swatch date
            return $this->swatchDate($timestamp).' � '.$this->swatchTime($timestamp);
            break;
            case 2:
                // iso date
            return $this->unixTimestampToISOdatetime($timestamp);
            break;
            default:
                // default time
            return date($this->dateFilter($format, $timestamp), $timestamp);
            break;
        }
    }
401272
protected function humanDateOther($parsedTxt, \DateTime $current)
    {
        $currentClass = get_called_class();
        
        $dateFormat = $currentClass::$humanReadableFormats['dateDifferentYear'];
        if ($current->format('Y') === $this->format('Y')) {
            $dateFormat = $currentClass::$humanReadableFormats['dateSameYear'];
        }
        
        $parsedTxt->date = $currentClass::$humanReadableI18n['others'];
        $parsedTxt->time = $currentClass::$humanReadableI18n['time_part'];
        
        $date = $this->format($dateFormat);
        $time = $this->format($currentClass::$humanReadableFormats['time']);
        
        $this->humanParseDateAndTimeText($parsedTxt, $date, $time);
    }
1369157
private static function parseDateTime(EventDispatcherInterface $dispatcher, $dateFormat, $timeStamp)
    {
        $dateEvent = new ParseDateEvent($timeStamp, $dateFormat);
        $dispatcher->dispatch(ContaoEvents::DATE_PARSE, $dateEvent);

        return $dateEvent->getResult();
    }