#73 Use proper time tag

Uzavrená
otvorené 6 rokov pred užívateľom necklace · 3 komentárov

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 okomentoval 6 rokov pred
Vlastník

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 okomentoval 6 rokov pred
Autor

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 okomentoval 6 rokov pred
Vlastník

Merged it. Seems to work fine.

Merged it. Seems to work fine.
zPlus zatvorené 6 rokov pred
Prihláste sa pre zapojenie do konverzácie.
Žiadne štítky
Žiadny míľnik
Žiadny priradený
2 účastníkov
Načítavanie...
Zrušiť
Uložiť
Zatiaľ neexistuje žiadny obsah.