#73 Use proper time tag

Kapalı
necklace tarafından 6 yıl önce kere açıldı · 3 yorum
Nichlas Severinsen 6 yıl önce olarak yorumlandı

Currently the template looks like this:

<em><a href="post/{{ post.hashId }}">{{ post.created|ago }}</a></em>

Which generates html like this:

<a href="post/afcpgbmx1i">3 hours ago</a>

This makes it hard to know exactly when a post was really posted, especially when it says "x years ago", which really could mean anything.

Instead, the template should use the time tag, and generate html like this:

<time title="May 28, 2018, 3:47 PM PST">six minutes ago</time>

This allows users to hover their mouse over to get the exact time.

Though since this is a link I'll assume it really should generate html like this:

<em><a href="post/{{ post.hashId }}"><time title="May 28, 2018, 3:47 PM PST">six minutes ago</time></a></em>

But this is beyond the point and implicitly implied.

My example is from the index.twig template, but this should really be applied everywhere time is needed.

Currently the template looks like this: ``` <em><a href="post/{{ post.hashId }}">{{ post.created|ago }}</a></em> ``` Which generates html like this: ``` <a href="post/afcpgbmx1i">3 hours ago</a> ``` This makes it hard to know exactly when a post was really posted, especially when it says "x years ago", which really could mean anything. Instead, the template should use the [time](https://dev.w3.org/html5/html-author/#the-time-element) tag, and generate html like this: ``` <time title="May 28, 2018, 3:47 PM PST">six minutes ago</time> ``` This allows users to hover their mouse over to get the exact time. Though since this is a link I'll assume it really should generate html like this: ``` <em><a href="post/{{ post.hashId }}"><time title="May 28, 2018, 3:47 PM PST">six minutes ago</time></a></em> ``` But this is beyond the point and implicitly implied. My example is from the index.twig template, but this should really be applied everywhere time is needed.
zPlus 6 yıl önce olarak yorumlandı
Sahibi

This is a good idea. The reason to use "ago" was simply to avoid timezones, but using a <time> tag like that (maybe with UTC) would be perfectly fine.

This is a good idea. The reason to use "ago" was simply to avoid timezones, but using a `<time>` tag like that (maybe with `UTC`) would be perfectly fine.
Nichlas Severinsen 6 yıl önce olarak yorumlandı
Poster

Just to clarify, I don't mind the "ago" in the text part of it, that's perfectly fine (and pretty much standard now a days), I just think there should be a way to see exactly when. I was thinking UTC - not sure how it's stored in the DB - but I notice now that my example has "PST" in it, sorry 'bout that. Either way, whichever is easier, if the server isn't UTC then use whatever timezone the data is stored in.

I'm not very familiar with the code base but with a quick git grep on |ago it seems these are the templates that need changing (with line number):

template/comment.twig:25:
template/edit_comment.twig:10:
template/edit_post.twig:16:
template/index.twig:55:
template/post.twig:26:
template/reply.twig:7:
template/search.twig:21:
template/user.twig:25:
template/user.twig:83:
template/user_comments.twig:14:
template/user_posts.twig:22:
template/user_replies.twig:15:
Just to clarify, I don't mind the "ago" in the text part of it, that's perfectly fine (and pretty much standard now a days), I just think there should be a way to see exactly when. I was thinking UTC - not sure how it's stored in the DB - but I notice now that my example has "PST" in it, sorry 'bout that. Either way, whichever is easier, if the server isn't UTC then use whatever timezone the data is stored in. I'm not very familiar with the code base but with a quick `git grep` on `|ago` it seems these are the templates that need changing (with line number): ``` template/comment.twig:25: template/edit_comment.twig:10: template/edit_post.twig:16: template/index.twig:55: template/post.twig:26: template/reply.twig:7: template/search.twig:21: template/user.twig:25: template/user.twig:83: template/user_comments.twig:14: template/user_posts.twig:22: template/user_replies.twig:15: ```
zPlus 6 yıl önce olarak yorumlandı
Sahibi

Merged it. Seems to work fine.

Merged it. Seems to work fine.
Giriş yap bu konuşmaya katılmak için.
Kilometre Taşı Yok
Atanan Kişi Yok
2 Katılımcı
Yükleniyor...
İptal
Kaydet
Henüz bir içerik yok.