Skip to content

Commit 3ec4d12

Browse files
authored
Improve notification timestamp format (hestiacp#4237)
1 parent 2b7f0d4 commit 3ec4d12

File tree

6 files changed

+27
-16
lines changed

6 files changed

+27
-16
lines changed

bin/v-list-user-notifications

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# example: v-list-user-notifications admin
66
#
7-
# This function for getting the list notifications
7+
# This function for getting the notifications list
88

99
#----------------------------------------------------------#
1010
# Variables & Functions #

docs/docs/user-guide/notifications.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
To view your notifications, click the <i class="fas fa-lg fa-fw fa-bell"><span class="visually-hidden">notification</span></i> icon in the top right.
44

5-
You can dismiss a notification by clicking the small red circle on its right.
5+
You can delete a notification by clicking the small red "X" on the top right.

web/list/notifications/index.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,28 @@
22
// Main include
33
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
44

5+
function formatNotificationTimestamps(&$note) {
6+
$dateTime = DateTime::createFromFormat("Y-m-d H:i:s", $note["DATE"] . " " . $note["TIME"]);
7+
$note["TIMESTAMP_TEXT"] = $dateTime->format("d M Y, H:i");
8+
$note["TIMESTAMP_ISO"] = $dateTime->format(DateTime::ATOM); // ISO 8601 format
9+
$note["TIMESTAMP_TITLE"] = $dateTime->format("d F Y, H:i:s");
10+
}
11+
512
if ($_REQUEST["ajax"] == 1 && $_REQUEST["token"] == $_SESSION["token"]) {
613
// Data
714
exec(HESTIA_CMD . "v-list-user-notifications $user json", $output, $return_var);
815
$data = json_decode(implode("", $output), true);
916

10-
function sort_priorty_id($element1, $element2) {
17+
foreach ($data as $key => &$note) {
18+
formatNotificationTimestamps($note);
19+
}
20+
unset($note);
21+
22+
function sort_priority_id($element1, $element2) {
1123
return $element2["PRIORITY"] <=> $element1["PRIORITY"];
1224
}
1325
$data = array_reverse($data, true);
14-
usort($data, sort_priorty_id(...));
26+
usort($data, "sort_priority_id");
1527

1628
foreach ($data as $key => $note) {
1729
$note["ID"] = $key;

web/templates/includes/panel.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ class="top-bar-notification-delete"
114114
<div class="top-bar-notification-content" x-html="notification.NOTICE"></div>
115115
<p class="top-bar-notification-timestamp">
116116
<time
117-
:datetime="`${notification.DATE}T${notification.TIME}`"
118-
x-text="`${notification.TIME} ${notification.DATE}`"
117+
:datetime="`${notification.TIMESTAMP_ISO}`"
118+
x-bind:title="`${notification.TIMESTAMP_TITLE}`"
119+
x-text="`${notification.TIMESTAMP_TEXT}`"
119120
></time>
120121
</p>
121122
</li>

web/templates/pages/add_cron.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@
2525
<div class="u-side-by-side-tablet u-mb20">
2626
<h1><?= _("Add Cron Job") ?></h1>
2727
<p>
28-
<?= _('System time') ?>: <span class="u-text-bold">
29-
<time datetime="<?= date("c", $current_timestamp) ?>">
30-
<?= date("d M Y, H:i", $current_timestamp) ?>
31-
</time>
32-
</span>
28+
<?= _('System time') ?>:
29+
<time datetime="<?= date("c", $current_timestamp) ?>" class="u-text-bold">
30+
<?= date("d M Y, H:i", $current_timestamp) ?>
31+
</time>
3332
</p>
3433
</div>
3534
<?php show_alert_message($_SESSION); ?>

web/templates/pages/edit_cron.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@
2525
<div class="u-side-by-side-tablet u-mb20">
2626
<h1><?= _("Edit Cron Job") ?></h1>
2727
<p>
28-
<?= _('System time') ?>: <span class="u-text-bold">
29-
<time datetime="<?= date("c", $current_timestamp) ?>">
30-
<?= date("d M Y, H:i", $current_timestamp) ?>
31-
</time>
32-
</span>
28+
<?= _('System time') ?>:
29+
<time datetime="<?= date("c", $current_timestamp) ?>" class="u-text-bold">
30+
<?= date("d M Y, H:i", $current_timestamp) ?>
31+
</time>
3332
</p>
3433
</div>
3534
<?php show_alert_message($_SESSION); ?>

0 commit comments

Comments
 (0)