optimizations (#2904)

* calc once, then re-use
* prevent invalid theme switch
* allow to turn off weekly-quick-entries by permissions
* remove 00:00 from date-times that likely do not need a time
* fix datepicker out of window
This commit is contained in:
Kevin Papst
2021-11-05 10:28:48 +01:00
committed by GitHub
parent c8854b0775
commit bd2fe32d5a
21 changed files with 64 additions and 45 deletions

View File

@@ -239,9 +239,10 @@ final class LocaleFormatter
/**
* @param DateTime|string $date
* @param bool $stripMidnight
* @return bool|false|string
*/
public function dateTimeFull($date)
public function dateTimeFull($date, bool $stripMidnight = false)
{
if (null === $this->dateTimeTypeFormat) {
$this->dateTimeTypeFormat = $this->localeFormats->getDateTimeTypeFormat();
@@ -255,13 +256,19 @@ final class LocaleFormatter
}
}
$format = $this->dateTimeTypeFormat;
if ($stripMidnight && $date->format('H') == '00' && $date->format('i') == '00') {
$format = $this->localeFormats->getDateTypeFormat();
}
$formatter = new IntlDateFormatter(
$this->locale,
IntlDateFormatter::MEDIUM,
IntlDateFormatter::MEDIUM,
date_default_timezone_get(),
IntlDateFormatter::GREGORIAN,
$this->dateTimeTypeFormat
$format
);
return $formatter->format($date);