diff --git a/assets/misuzu.css/forum/categories.css b/assets/misuzu.css/forum/categories.css
index efd55e5..3e579bf 100644
--- a/assets/misuzu.css/forum/categories.css
+++ b/assets/misuzu.css/forum/categories.css
@@ -139,7 +139,7 @@
.forum__category__activity {
text-align: right;
min-width: 270px;
- line-height: 1.5em;
+ line-height: 1.4em;
}
.forum__category__activity__none,
.forum__category__activity__details {
@@ -171,6 +171,7 @@
color: var(--user-colour);
text-decoration: none;
pointer-events: initial;
+ display: block;
}
.forum__category__username:hover,
.forum__category__username:focus {
@@ -229,4 +230,7 @@
.forum__category__avatar {
display: none;
}
-}
\ No newline at end of file
+ .forum__category__username {
+ display: none;
+ }
+}
diff --git a/src/TwigMisuzu.php b/src/TwigMisuzu.php
index 0cf2b10..06a7655 100644
--- a/src/TwigMisuzu.php
+++ b/src/TwigMisuzu.php
@@ -1,15 +1,16 @@
Parser::instance($parser)->parseText($text)),
new TwigFilter('parse_comment', fn(string $text): string => CommentsParser::parseForDisplay($text)),
new TwigFilter('perms_check', 'perms_check'),
- new TwigFilter('time_diff', [$this, 'timeDiff'], ['needs_environment' => true]),
+ new TwigFilter('time_format', [$this, 'timeFormat']),
];
}
@@ -53,32 +54,25 @@ final class TwigMisuzu extends AbstractExtension {
return compact('ndx', 'pdo', 'total');
}
- public static $units = [
- 'y' => 'year',
- 'm' => 'month',
- 'd' => 'day',
- 'h' => 'hour',
- 'i' => 'minute',
- 's' => 'second',
- ];
+ public function timeFormat(DateTime|string|int $dateTime): string {
+ if(is_string($dateTime))
+ $dateTime = new DateTime($dateTime);
+ elseif(is_int($dateTime))
+ $dateTime = DateTime::fromUnixTimeSeconds($dateTime);
- // yoinked from https://github.com/twigphp/Twig-extensions/blob/0c7a08e6de42a3c8f6a68af9628f4c8e4e00de93/src/DateExtension.php
- public function timeDiff(TwigEnvironment $env, $date, $now = null) {
- $date = \twig_date_converter($env, $date);
- $now = \twig_date_converter($env, $now);
+ $string = '';
+ $now = DateTime::now();
- $diff = $date->diff($now);
-
- foreach(self::$units as $attr => $unit) {
- $count = $diff->{$attr};
-
- if($count !== 0) {
- if($count !== 1)
- $unit .= 's';
- return $diff->invert ? "in {$count} {$unit}" : "{$count} {$unit} ago";
- }
+ $isDiffYear = $now->getYear() !== $dateTime->getYear();
+ if($isDiffYear || $now->getMonth() !== $dateTime->getMonth() || $now->getDay() !== $dateTime->getDay()) {
+ $string .= $dateTime->format('M jS');
+ if($isDiffYear)
+ $string .= $dateTime->format(' Y');
+ $string .= ', ';
}
- return 'just now';
+ $string .= $dateTime->format('G:i T');
+
+ return $string;
}
}
diff --git a/templates/_layout/comments.twig b/templates/_layout/comments.twig
index ee01b42..55e01a5 100644
--- a/templates/_layout/comments.twig
+++ b/templates/_layout/comments.twig
@@ -86,7 +86,7 @@
{% if comment.pinned %}
@@ -95,7 +95,7 @@
{% if comment.pinnedTime != comment.createdTime %}
{% endif %}
{% endapply %}
@@ -181,7 +181,7 @@
{% elseif not user.commentPerms.can_lock|default(false) and category.locked %}
{% elseif not user.commentPerms.can_comment|default(false) %}
@@ -241,7 +237,7 @@
This topic was locked
.
+ title="{{ locked|date('r') }}">{{ locked|time_format }}.
{% endif %}
{% endset %}
{{ forum_topic_notice(archived ? 'archive' : 'lock', body) }}
@@ -317,7 +313,7 @@
style="{{ topic.author_colour|html_colour }}">{{ topic.author_name }},
{% endif %}
-
+
{% if topic.topic_pages|default(0) > 1 %}
@@ -361,7 +357,7 @@
+ title="{{ topic.response_created|date('r') }}">{{ topic.response_created|time_format }}
@@ -427,7 +423,7 @@
{% endif %}
- joined
+ joined
{% else %}
Deleted User
@@ -440,9 +436,9 @@
- joined
+ joined
diff --git a/templates/home/home.twig b/templates/home/home.twig
index fd7b7c9..43ea30f 100644
--- a/templates/home/home.twig
+++ b/templates/home/home.twig
@@ -103,7 +103,7 @@
{{ latest_user.username }}
- Joined
+ Joined
diff --git a/templates/home/landing.twig b/templates/home/landing.twig
index 738f657..1130239 100644
--- a/templates/home/landing.twig
+++ b/templates/home/landing.twig
@@ -175,7 +175,7 @@
{{ post.firstParagraph|parse_text(2)|raw }}
Continue reading
- | {{ post.createdTime|time_diff }}
+ | {{ post.createdTime|time_format }}
{% endfor %}
diff --git a/templates/manage/forum/redirs.twig b/templates/manage/forum/redirs.twig
index 370b339..ec757a2 100644
--- a/templates/manage/forum/redirs.twig
+++ b/templates/manage/forum/redirs.twig
@@ -62,7 +62,7 @@
|
diff --git a/templates/manage/users/users.twig b/templates/manage/users/users.twig
index b2156c8..a770446 100644
--- a/templates/manage/users/users.twig
+++ b/templates/manage/users/users.twig
@@ -27,18 +27,18 @@
- /
+ /
{{ user.registerRemoteAddress }}
- /
+ /
{{ user.lastRemoteAddress }}
{% if user.isDeleted %}
-
+
{% endif %}
diff --git a/templates/news/macros.twig b/templates/news/macros.twig
index 83d7839..6f08412 100644
--- a/templates/news/macros.twig
+++ b/templates/news/macros.twig
@@ -24,7 +24,7 @@
Posted
@@ -71,7 +71,7 @@
Posted
@@ -79,7 +79,7 @@
Updated
{% endif %}
diff --git a/templates/profile/_layout/header.twig b/templates/profile/_layout/header.twig
index f681e7c..fd78c0a 100644
--- a/templates/profile/_layout/header.twig
+++ b/templates/profile/_layout/header.twig
@@ -94,7 +94,7 @@
{% if is_date %}
{% else %}
@@ -257,7 +257,7 @@
Last Active
{% endif %}
@@ -310,7 +310,7 @@
Attempted
@@ -363,7 +363,7 @@
Date
@@ -433,7 +433,7 @@
{% if warning.isPermanent %}