Browse Source

affiche les dates passées en rouge

master
vince vince 2 years ago
parent
commit
4a9800225e
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      index.php

+ 8
- 1
index.php View File

@ -25,6 +25,12 @@ if (preg_match(REQUEST_REGEX, $requestUrl, $match)) {
$requestEvent = null;
}
function isInPast($event) {
$now = new \DateTimeImmutable('now');
$then = new \DateTimeImmutable($event);
return $then->getTimestamp() < $now->getTimestamp();
}
function ago($value) {
$now = new \DateTimeImmutable('now 00:00:00');
$value = (clone $value)->setTime(0, 0, 0);
@ -122,7 +128,7 @@ if ($hasSupplier) {
$config[$supplier] = array_merge(
[
'title' => '',
'subtitle' => '<small class="text-muted text-nowrap d-block d-sm-inline">%date% (%ago%)</small>',
'subtitle' => '<small class="%color% text-nowrap d-block d-sm-inline">%date% (%ago%)</small>',
'description' => '',
'choices' => [],
'start' => 'now 00:00:00',
@ -322,6 +328,7 @@ if (!$isConfig and !$supplierIsNew and $hasSupplier) {
$date = (new \IntlDateFormatter('fr_FR.UTF8', \IntlDateFormatter::FULL, \IntlDateFormatter::NONE, 'Europe/Paris'))->format(new \DateTime($event));
$ago = ago(new \DateTimeImmutable($event));
$color = isInPast($event) ? 'text-danger' : 'text-muted';
foreach (['title', 'subtitle', 'description'] as $key) {
while (preg_match('/%([^%]+)%/i', $config[$supplier][$key], $match))


Loading…
Cancel
Save