aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2024-12-07 20:41:13 +0000
committerMario <mario@mariovavti.com>2024-12-07 20:41:13 +0000
commite88ae54bef268e455b6d6028a697e9dbd98a7853 (patch)
tree78c160441f712e0095ead75a2653c47f6510d68b
parentd37d181d9425abcd04b36fc0c5e947a588497599 (diff)
downloadvolse-hubzilla-e88ae54bef268e455b6d6028a697e9dbd98a7853.tar.gz
volse-hubzilla-e88ae54bef268e455b6d6028a697e9dbd98a7853.tar.bz2
volse-hubzilla-e88ae54bef268e455b6d6028a697e9dbd98a7853.zip
add more indicators and a new function to return relative time in the past and the future
-rw-r--r--Zotlabs/Lib/ThreadItem.php6
-rw-r--r--include/datetime.php34
-rw-r--r--view/tpl/conv_item.tpl9
-rw-r--r--view/tpl/conv_list.tpl9
-rw-r--r--view/tpl/search_item.tpl16
5 files changed, 60 insertions, 14 deletions
diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php
index ae5954a62..4b833f4b4 100644
--- a/Zotlabs/Lib/ThreadItem.php
+++ b/Zotlabs/Lib/ThreadItem.php
@@ -414,11 +414,11 @@ class ThreadItem {
'str_app' => sprintf( t('from %s'), $item['app']),
'isotime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'c'),
'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created']),
- 'editedtime' => (($item['edited'] != $item['created']) ? sprintf( t('Last edited %s'), datetime_convert('UTC', date_default_timezone_get(), $item['edited'])) : ''),
- 'expiretime' => (($item['expires'] > NULL_DATE) ? sprintf( t('Expires %s'), datetime_convert('UTC', date_default_timezone_get(), $item['expires'])) : ''),
+ 'editedtime' => (($item['edited'] != $item['created']) ? sprintf(t('Last edited %s'), relative_time($item['edited'])) : ''),
+ 'expiretime' => (($item['expires'] > NULL_DATE) ? sprintf(t('Expires %s'), relative_time($item['expires'])) : ''),
'lock' => $lock,
'locktype' => $locktype,
- 'delayed' => $item['item_delayed'],
+ 'delayed' => (($item['item_delayed']) ? sprintf(t('Published %s'), relative_time($item['created'])) : ''),
'privacy_warning' => $privacy_warning,
'verified' => $verified,
'unverified' => $unverified,
diff --git a/include/datetime.php b/include/datetime.php
index 2182d7c43..e23a11741 100644
--- a/include/datetime.php
+++ b/include/datetime.php
@@ -268,6 +268,40 @@ function relative_date($posted_date, $format = null) {
return $abs;
}
+
+function relative_time($timestamp) {
+ $timestamp = datetime_convert('UTC', date_default_timezone_get(), $timestamp);
+
+ $now = new DateTime();
+ $time = new DateTime($timestamp);
+
+ $interval = $now->diff($time);
+
+ $prefix = '';
+ $appendix = ' ' . t('ago');
+
+ if ($time > $now) {
+ $prefix = t('in') . ' ';
+ $appendix = '';
+ }
+
+ if ($interval->y > 0) {
+ return $prefix . $interval->y . ' ' . plural_dates('y', $interval->y) . $appendix;
+ } elseif ($interval->m > 0) {
+ return $prefix . $interval->m . ' ' . plural_dates('m', $interval->m) . $appendix;
+ } elseif ($interval->d > 0) {
+ return $prefix . $interval->d . ' ' . plural_dates('d', $interval->d) . $appendix;
+ } elseif ($interval->h > 0) {
+ return $prefix . $interval->h . ' ' . plural_dates('h', $interval->h) . $appendix;
+ } elseif ($interval->i > 0) {
+ return $prefix . $interval->i . ' ' . plural_dates('i', $interval->i) . $appendix;
+ } elseif ($interval->s > 0) {
+ return $prefix . $interval->s . ' ' . plural_dates('s', $interval->s) . $appendix;
+ } else {
+ return t('now');
+ }
+}
+
function plural_dates($k,$n) {
switch($k) {
diff --git a/view/tpl/conv_item.tpl b/view/tpl/conv_item.tpl
index 56f590284..96e6f57df 100644
--- a/view/tpl/conv_item.tpl
+++ b/view/tpl/conv_item.tpl
@@ -32,9 +32,6 @@
{{if $item.location}}
{{$item.location}}
{{/if}}
- {{if $item.delayed}}
- <i class="bi bi-clock"></i>
- {{/if}}
{{if $item.editedtime}}
<i class="bi bi-pencil" title="{{$item.editedtime}}"></i>
{{/if}}
@@ -46,6 +43,12 @@
{{if $item.no_comment}}
<i class="bi bi-ban" title="{{$item.no_comment}}"></i>
{{/if}}
+ {{if $item.delayed}}
+ <i class="bi bi-clock" title="{{$item.delayed}}"></i>
+ {{/if}}
+ {{if $item.expiretime}}
+ <i class="bi bi-clock-history" title="{{$item.expiretime}}"></i>
+ {{/if}}
<small class="autotime" title="{{$item.isotime}}"><time class="dt-published" datetime="{{$item.isotime}}">{{$item.localtime}}</time>{{if $item.expiretime}}&nbsp;{{$item.expiretime}}{{/if}}</small>
</div>
{{if $item.thr_parent_uuid}}
diff --git a/view/tpl/conv_list.tpl b/view/tpl/conv_list.tpl
index f31424ce3..6143e156e 100644
--- a/view/tpl/conv_list.tpl
+++ b/view/tpl/conv_list.tpl
@@ -26,9 +26,6 @@
{{if $item.location}}
{{$item.location}}
{{/if}}
- {{if $item.delayed}}
- <i class="bi bi-clock"></i>
- {{/if}}
{{if $item.editedtime}}
<i class="bi bi-pencil" title="{{$item.editedtime}}"></i>
{{/if}}
@@ -40,6 +37,12 @@
{{if $item.no_comment}}
<i class="bi bi-ban" title="{{$item.no_comment}}"></i>
{{/if}}
+ {{if $item.delayed}}
+ <i class="bi bi-clock" title="{{$item.delayed}}"></i>
+ {{/if}}
+ {{if $item.expiretime}}
+ <i class="bi bi-clock-history" title="{{$item.expiretime}}"></i>
+ {{/if}}
<small class="autotime" title="{{$item.isotime}}"><time class="dt-published" datetime="{{$item.isotime}}">{{$item.localtime}}</time>{{if $item.expiretime}}&nbsp;{{$item.expiretime}}{{/if}}</small>
</div>
{{if $item.pinned}}
diff --git a/view/tpl/search_item.tpl b/view/tpl/search_item.tpl
index 709e40a13..d693c4d37 100644
--- a/view/tpl/search_item.tpl
+++ b/view/tpl/search_item.tpl
@@ -26,18 +26,24 @@
{{if $item.location}}
{{$item.location}}
{{/if}}
- {{if $item.delayed}}
- <i class="bi bi-clock"></i>
- {{/if}}
{{if $item.editedtime}}
- <i class="bi bi-pencil"></i>
+ <i class="bi bi-pencil" title="{{$item.editedtime}}"></i>
{{/if}}
{{if $item.verified}}
<i class="bi bi-shield-check" title="{{$item.verified}}"></i>
{{elseif $item.forged}}
<i class="bi bi-shield-exclamation text-danger" title="{{$item.forged}}"></i>
{{/if}}
- <small class="autotime" title="{{$item.isotime}}"><time class="dt-published" datetime="{{$item.isotime}}">{{$item.localtime}}</time>{{if $item.editedtime}}&nbsp;{{$item.editedtime}}{{/if}}{{if $item.expiretime}}&nbsp;{{$item.expiretime}}{{/if}}</small>
+ {{if $item.no_comment}}
+ <i class="bi bi-ban" title="{{$item.no_comment}}"></i>
+ {{/if}}
+ {{if $item.delayed}}
+ <i class="bi bi-clock" title="{{$item.delayed}}"></i>
+ {{/if}}
+ {{if $item.expiretime}}
+ <i class="bi bi-clock-history" title="{{$item.expiretime}}"></i>
+ {{/if}}
+ <small class="autotime" title="{{$item.isotime}}"><time class="dt-published" datetime="{{$item.isotime}}">{{$item.localtime}}</time>{{if $item.expiretime}}&nbsp;{{$item.expiretime}}{{/if}}</small>
</div>
{{if $item.pinned}}
<div class="wall-item-pinned" title="{{$item.pinned}}" id="wall-item-pinned-{{$item.id}}"><i class="bi bi-pin-fill"></i></div>