summaryrefslogtreecommitdiffstats
path: root/inc
diff options
context:
space:
mode:
authorSimon Rettberg2025-05-20 14:46:33 +0200
committerSimon Rettberg2025-05-20 14:46:33 +0200
commitf4892df57711f0b564d55ba63c0ebdbb115ca40d (patch)
treee020dbb301e52871a0ec70eec7da6e8b894a7f50 /inc
parent[inc/Database] Check if ErrorHandler is available before calling it (diff)
downloadslx-admin-f4892df57711f0b564d55ba63c0ebdbb115ca40d.tar.gz
slx-admin-f4892df57711f0b564d55ba63c0ebdbb115ca40d.tar.xz
slx-admin-f4892df57711f0b564d55ba63c0ebdbb115ca40d.zip
[eventlog] Don't use "smart"/relative time in events
Diffstat (limited to 'inc')
-rw-r--r--inc/audit.inc.php1
-rw-r--r--inc/util.inc.php5
2 files changed, 4 insertions, 2 deletions
diff --git a/inc/audit.inc.php b/inc/audit.inc.php
new file mode 100644
index 00000000..b3d9bbc7
--- /dev/null
+++ b/inc/audit.inc.php
@@ -0,0 +1 @@
+<?php
diff --git a/inc/util.inc.php b/inc/util.inc.php
index ed0b40ae..91232f46 100644
--- a/inc/util.inc.php
+++ b/inc/util.inc.php
@@ -335,16 +335,17 @@ class Util
* The format depends on how far the timestamp lies in the past.
*
* @param int $ts unix timestamp
+ * @param bool $useSmartAbbreviation use words like "yesterday", leave out year, if applicable
* @return string human-readable representation
*/
- public static function prettyTime(int $ts): string
+ public static function prettyTime(int $ts, bool $useSmartAbbreviation = true): string
{
settype($ts, 'int');
if ($ts === 0)
return '???';
static $TODAY = false, $ETODAY = false, $YESTERDAY = false, $YEARCUTOFF = false;
if (!$ETODAY) $ETODAY = strtotime('today 23:59:59');
- if ($ts > $ETODAY) // TODO: Do we need strings for future too?
+ if (!$useSmartAbbreviation || $ts > $ETODAY) // TODO: Do we need strings for future too?
return date('d.m.Y H:i', $ts);
if (!$TODAY) $TODAY = strtotime('today 0:00');
if ($ts >= $TODAY)