diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2024-12-16 04:39:54 +0000 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2024-12-16 04:39:54 +0000 |
| commit | 13804c4beb3b5299829e756130753cc21956df57 (patch) | |
| tree | 82299fdc13a4e0950126c0ec889d4a9e020748f6 /classes/TimeHelper.php | |
| parent | d5b1258d294fb8b0e43344a9925a9202925fcb02 (diff) | |
| parent | f9b2291c28e7036276134aac84ec456fbd297d30 (diff) | |
Merge branch 'feature/smart_date_time_never' into 'master'
Consistently "smart display" the Unix epoch as "Never", clean up calls to `TimeHelper::make_local_datetime()`
See merge request tt-rss/tt-rss!89
Diffstat (limited to 'classes/TimeHelper.php')
| -rw-r--r-- | classes/TimeHelper.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/classes/TimeHelper.php b/classes/TimeHelper.php index 07df3b87c..c39391eea 100644 --- a/classes/TimeHelper.php +++ b/classes/TimeHelper.php @@ -2,6 +2,10 @@ class TimeHelper { static function smart_date_time(int $timestamp, int $tz_offset = 0, ?int $owner_uid = null, bool $eta_min = false): string { + // i.e. if the Unix epoch + if ($timestamp - $tz_offset === 0) + return __('Never'); + if (!$owner_uid) $owner_uid = $_SESSION['uid']; $profile = isset($_SESSION['uid']) && $owner_uid == $_SESSION['uid'] && isset($_SESSION['profile']) ? $_SESSION['profile'] : null; @@ -22,7 +26,10 @@ class TimeHelper { } } - static function make_local_datetime(?string $timestamp, bool $long, ?int $owner_uid = null, + /** + * @param bool $long Whether to display the datetime in a 'long' format. Only used if $no_smart_dt is true. + */ + static function make_local_datetime(?string $timestamp, bool $long = false, ?int $owner_uid = null, bool $no_smart_dt = false, bool $eta_min = false): string { if (!$owner_uid) $owner_uid = $_SESSION['uid']; |