diff --git a/public_html/media/css/comment-small.css b/public_html/media/css/comment-small.css index 11069cad..beef4da9 100644 --- a/public_html/media/css/comment-small.css +++ b/public_html/media/css/comment-small.css @@ -22,11 +22,8 @@ .comment { clear: left; } -.comment .date:before { - content: ' on '; - margin: 0 0.2em; -} .comment .date { + margin: 0 0.2em 0 0.75em; color: silver; } diff --git a/src/Helpers/TextHelper.php b/src/Helpers/TextHelper.php index b772321b..3796f4ea 100644 --- a/src/Helpers/TextHelper.php +++ b/src/Helpers/TextHelper.php @@ -284,4 +284,48 @@ class TextHelper return $html; } + + public static function formatDate($date, $plain = true) + { + if (!$date) + return 'Unknown'; + if ($plain) + return date('Y-m-d H:i:s', $date); + + $now = time(); + $diff = abs($now - $date); + $future = $now < $date; + + $mul = 60; + if ($diff < $mul) + return $future ? 'in a few seconds' : 'just now'; + if ($diff < $mul * 2) + return $future ? 'in a minute' : 'a minute ago'; + + $prevMul = $mul; $mul *= 60; + if ($diff < $mul) + return $future ? 'in ' . round($diff / $prevMul) . ' minutes' : round($diff / $prevMul) . ' minutes ago'; + if ($diff < $mul * 2) + return $future ? 'in an hour' : 'an hour ago'; + + $prevMul = $mul; $mul *= 24; + if ($diff < $mul) + return $future ? 'in ' . round($diff / $prevMul) . ' hours' : round($diff / $prevMul) . ' hours ago'; + if ($diff < $mul * 2) + return $future ? 'tomorrow' : 'yesterday'; + + $prevMul = $mul; $mul *= 30.42; + if ($diff < $mul) + return $future ? 'in ' . round($diff / $prevMul) . ' days' : round($diff / $prevMul) . ' days ago'; + if ($diff < $mul * 2) + return $future ? 'in a month' : 'a month ago'; + + $prevMul = $mul; $mul *= 12; + if ($diff < $mul) + return $future ? 'in ' . round($diff / $prevMul) . ' months' : round($diff / $prevMul) . ' months ago'; + if ($diff < $mul * 2) + return $future ? 'in a year' : 'a year ago'; + + return $future ? 'in ' . round($diff / $mul) . ' years' : round($diff / $prevMul) . ' years ago'; + } } diff --git a/src/Views/comment-small.phtml b/src/Views/comment-small.phtml index 3e7918cd..f9567def 100644 --- a/src/Views/comment-small.phtml +++ b/src/Views/comment-small.phtml @@ -28,8 +28,8 @@ LayoutHelper::addScript('comment-edit.js'); - - context->comment->commentDate) ?> + + context->comment->commentDate, false) ?> diff --git a/src/Views/post-view.phtml b/src/Views/post-view.phtml index 262d73e8..60d51e99 100644 --- a/src/Views/post-view.phtml +++ b/src/Views/post-view.phtml @@ -117,9 +117,9 @@ LayoutHelper::addScript('../lib/tagit/jquery.tagit.js');
- Date: - - + Uploaded: + + context->transport->post->uploadDate, false) ?>
diff --git a/src/Views/user-list.phtml b/src/Views/user-list.phtml index bcc6eccc..aea5c4b4 100644 --- a/src/Views/user-list.phtml +++ b/src/Views/user-list.phtml @@ -50,9 +50,17 @@ if ($this->context->user->hasEnabledEndlessScrolling()) -
Registered: joinDate) ?>
-
Favorite count: getFavoriteCount() ?>
-
Post count: getPostCount() ?>
+
+ Registered: joinDate, false) ?> +
+ +
+ Uploaded: getPostCount()) ?> +
+ +
+ Favorites: getFavoriteCount()) ?> +
diff --git a/src/Views/user-view.phtml b/src/Views/user-view.phtml index 4b2e0a00..567e855c 100644 --- a/src/Views/user-view.phtml +++ b/src/Views/user-view.phtml @@ -16,23 +16,33 @@ LayoutHelper::addStylesheet('user-view.css');
Joined: - + + context->transport->user->joinDate, false) ?> +
Last login: - + + context->transport->user->lastLoginDate, false) ?> +
Access rank: - + + +
context->transport->user))): ?>
E-mail: - + + +
(only you and staff can see this)