summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rw-r--r--classes/Counters.php6
-rw-r--r--classes/Digest.php3
-rw-r--r--classes/Feeds.php11
-rw-r--r--classes/Pref_Feeds.php8
-rw-r--r--classes/Pref_Filters.php2
-rw-r--r--classes/Pref_Prefs.php4
-rw-r--r--classes/Pref_System.php2
-rw-r--r--classes/Pref_Users.php10
-rw-r--r--classes/TimeHelper.php9
9 files changed, 27 insertions, 28 deletions
diff --git a/classes/Counters.php b/classes/Counters.php
index 99d4fdab1..e20657947 100644
--- a/classes/Counters.php
+++ b/classes/Counters.php
@@ -183,7 +183,7 @@ class Counters {
while ($line = $sth->fetch()) {
$id = $line["id"];
- $last_updated = TimeHelper::make_local_datetime($line['last_updated'], false);
+ $last_updated = TimeHelper::make_local_datetime($line['last_updated']);
if (Feeds::_has_icon($id)) {
$ts = filemtime(Feeds::_get_icon_file($id));
@@ -191,10 +191,6 @@ class Counters {
$ts = 0;
}
- // hide default un-updated timestamp i.e. 1970-01-01 (?) -fox
- if ((int)date('Y') - (int)date('Y', strtotime($line['last_updated'] ?? '')) > 2)
- $last_updated = '';
-
$cv = [
"id" => $id,
"updated" => $last_updated,
diff --git a/classes/Digest.php b/classes/Digest.php
index 7e5e660b6..3ce2693f3 100644
--- a/classes/Digest.php
+++ b/classes/Digest.php
@@ -153,8 +153,7 @@ class Digest
array_push($affected_ids, $line["ref_id"]);
- $updated = TimeHelper::make_local_datetime($line['last_updated'], false,
- $user_id);
+ $updated = TimeHelper::make_local_datetime($line['last_updated'], owner_uid: $user_id);
if (Prefs::get(Prefs::ENABLE_FEED_CATS, $user_id)) {
$line['feed_title'] = $line['cat_title'] . " / " . $line['feed_title'];
diff --git a/classes/Feeds.php b/classes/Feeds.php
index 39380cc01..3eab4e9f8 100644
--- a/classes/Feeds.php
+++ b/classes/Feeds.php
@@ -152,8 +152,7 @@ class Feeds extends Handler_Protected {
$feed_title = $qfh_ret[1];
$feed_site_url = $qfh_ret[2];
$last_error = $qfh_ret[3];
- $last_updated = str_contains($qfh_ret[4] ?? "", '1970-') ?
- __("Never") : TimeHelper::make_local_datetime($qfh_ret[4], false);
+ $last_updated = TimeHelper::make_local_datetime($qfh_ret[4]);
$highlight_words = $qfh_ret[5];
$reply['first_id'] = $qfh_ret[6];
$reply['is_vfeed'] = $qfh_ret[7];
@@ -338,11 +337,11 @@ class Feeds extends Handler_Protected {
$line["enclosures"] = [ 'formatted' => '', 'entries' => [] ];
}
- $line["updated_long"] = TimeHelper::make_local_datetime($line["updated"],true);
- $line["updated"] = TimeHelper::make_local_datetime($line["updated"], false, null, false, true);
+ $line["updated_long"] = TimeHelper::make_local_datetime($line["updated"]);
+ $line["updated"] = TimeHelper::make_local_datetime($line["updated"], eta_min: true);
$line['imported'] = T_sprintf("Imported at %s",
- TimeHelper::make_local_datetime($line["date_entered"], false));
+ TimeHelper::make_local_datetime($line['date_entered']));
if ($line["tag_cache"])
$tags = explode(",", $line["tag_cache"]);
@@ -417,7 +416,7 @@ class Feeds extends Handler_Protected {
$sth->execute([$_SESSION['uid']]);
$row = $sth->fetch();
- $last_updated = TimeHelper::make_local_datetime($row["last_updated"], false);
+ $last_updated = TimeHelper::make_local_datetime($row['last_updated']);
$reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
diff --git a/classes/Pref_Feeds.php b/classes/Pref_Feeds.php
index b8edd3eb7..537cc3c86 100644
--- a/classes/Pref_Feeds.php
+++ b/classes/Pref_Feeds.php
@@ -103,7 +103,7 @@ class Pref_Feeds extends Handler_Protected {
'param' => T_sprintf(
_ngettext("(%d article / %s)", "(%d articles / %s)", $feed->num_articles),
$feed->num_articles,
- TimeHelper::make_local_datetime($feed->last_updated, true)),
+ TimeHelper::make_local_datetime($feed->last_updated)),
'updates_disabled' => (int)($feed->update_interval < 0),
]);
}
@@ -290,7 +290,7 @@ class Pref_Feeds extends Handler_Protected {
'param' => T_sprintf(
_ngettext("(%d article / %s)", "(%d articles / %s)", $feed->num_articles),
$feed->num_articles,
- TimeHelper::make_local_datetime($feed->last_updated, true)),
+ TimeHelper::make_local_datetime($feed->last_updated)),
'unread' => -1,
'type' => 'feed',
'updates_disabled' => (int)($feed->update_interval < 0),
@@ -333,7 +333,7 @@ class Pref_Feeds extends Handler_Protected {
'param' => T_sprintf(
_ngettext("(%d article / %s)", "(%d articles / %s)", $feed->num_articles),
$feed->num_articles,
- TimeHelper::make_local_datetime($feed->last_updated, true)),
+ TimeHelper::make_local_datetime($feed->last_updated)),
'unread' => -1,
'type' => 'feed',
'updates_disabled' => (int)($feed->update_interval < 0),
@@ -1161,7 +1161,7 @@ class Pref_Feeds extends Handler_Protected {
->find_array();
foreach ($inactive_feeds as $inactive_feed) {
- $inactive_feed['last_article'] = TimeHelper::make_local_datetime($inactive_feed['last_article'], false);
+ $inactive_feed['last_article'] = TimeHelper::make_local_datetime($inactive_feed['last_article']);
}
print json_encode($inactive_feeds);
diff --git a/classes/Pref_Filters.php b/classes/Pref_Filters.php
index 46180e0cb..811644758 100644
--- a/classes/Pref_Filters.php
+++ b/classes/Pref_Filters.php
@@ -276,7 +276,7 @@ class Pref_Filters extends Handler_Protected {
'name' => $name[0],
'param' => $name[1],
'checkbox' => false,
- 'last_triggered' => $filter->last_triggered ? TimeHelper::make_local_datetime($filter->last_triggered, false) : null,
+ 'last_triggered' => $filter->last_triggered ? TimeHelper::make_local_datetime($filter->last_triggered) : null,
'enabled' => sql_bool_to_bool($filter->enabled),
'rules' => $this->_get_rules_list($filter->id)
];
diff --git a/classes/Pref_Prefs.php b/classes/Pref_Prefs.php
index 7d1c0e9eb..94c38c177 100644
--- a/classes/Pref_Prefs.php
+++ b/classes/Pref_Prefs.php
@@ -1520,10 +1520,10 @@ class Pref_Prefs extends Handler_Protected {
<?= htmlspecialchars($pass["title"]) ?>
</td>
<td class='text-muted'>
- <?= TimeHelper::make_local_datetime($pass['created'], false) ?>
+ <?= TimeHelper::make_local_datetime($pass['created']) ?>
</td>
<td class='text-muted'>
- <?= TimeHelper::make_local_datetime($pass['last_used'], false) ?>
+ <?= TimeHelper::make_local_datetime($pass['last_used']) ?>
</td>
</tr>
<?php } ?>
diff --git a/classes/Pref_System.php b/classes/Pref_System.php
index 885eabdac..225fc49b9 100644
--- a/classes/Pref_System.php
+++ b/classes/Pref_System.php
@@ -143,7 +143,7 @@ class Pref_System extends Handler_Administrative {
<td class='errstr'><?= $line["errstr"] . "\n" . $line["context"] ?></td>
<td class='login'><?= $line["login"] ?></td>
<td class='timestamp'>
- <?= TimeHelper::make_local_datetime($line["created_at"], false) ?>
+ <?= TimeHelper::make_local_datetime($line['created_at']) ?>
</td>
</tr>
<?php } ?>
diff --git a/classes/Pref_Users.php b/classes/Pref_Users.php
index 4b51cfd12..ef44dad30 100644
--- a/classes/Pref_Users.php
+++ b/classes/Pref_Users.php
@@ -35,11 +35,9 @@ class Pref_Users extends Handler_Administrative {
if ($row = $sth->fetch()) {
- $last_login = TimeHelper::make_local_datetime(
- $row["last_login"], true);
+ $last_login = TimeHelper::make_local_datetime($row['last_login']);
- $created = TimeHelper::make_local_datetime(
- $row["created"], true);
+ $created = TimeHelper::make_local_datetime($row['created']);
$stored_articles = $row["stored_articles"];
@@ -282,8 +280,8 @@ class Pref_Users extends Handler_Administrative {
</td>
<td><?= $access_level_names[$user["access_level"]] ?></td>
<td><?= $user["num_feeds"] ?></td>
- <td class='text-muted'><?= TimeHelper::make_local_datetime($user["created"], false) ?></td>
- <td class='text-muted'><?= TimeHelper::make_local_datetime($user["last_login"], false) ?></td>
+ <td class='text-muted'><?= TimeHelper::make_local_datetime($user['created']) ?></td>
+ <td class='text-muted'><?= TimeHelper::make_local_datetime($user['last_login']) ?></td>
</tr>
<?php } ?>
</table>
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'];