[Userscript] Detailed Timestamps

Prompted by @TheMusicalNinja mistaking “Apr 17” for “Apr '17”, and @plantron’s suggestion that Discourse should change their format.


What

Examples of the default timestamps are:
3m, 5h, 1d, Apr 17, Apr '17

As you see they tell us as little as possible and can easily cause confusion. This script provides more detailed timestamps. The table below uses relative time for anything less than 4 hours old, and relative dates for anything less than 7 day old. Where it stops being relative is, however, a setting at the top of the script, just like short format and 12- or 24-hour times are.

Let’s assume a post was posted 6:55 AM August 16, 2016.

Time since post Forum Default Short Format 12h Short Format 24h Long Format 12h Long Format 24h
30 seconds 1m < 1m < 1m < 1 minute < 1 minute
5 minutes 5m 5m 5m 5 minutes 5 minutes
1h 10m 1h 1h 10m 1h 10m 1 hour 10 minutes 1 hour 10 minutes
3h 31m 4h 3h 31m 3h 31m 3 hours 31 minutes 3 hours 31 minutes
4h 50m 5h 6:55 AM 06:55 Today at 6:55 AM Today at 06:55
1d 1h 1d 1d, 6:55 AM 1d, 06:55 Yesterday at 6:55 AM Yesterday at 06:55
2d 3h 2d 2d, 6:55 AM 2d, 06:55 2 days, 6:55 AM 2 days, 06:55
8d 8d Aug 16 6:55 AM Aug 16 06:55 Aug 16 6:55 AM Aug 16 06:55
2 months Aug 16 Aug 16 6:55 AM Aug 16 06:55 Aug 16 6:55 AM Aug 16 06:55
1 year Aug '16 Aug 16, 2016 Aug 16, 2016 Aug 16, 2016 Aug 16, 2016

The available settings are:

AmPmTimes: true or false depending on whether you’re on 12-hour or 24-hour clock.
shortFormat: true or false depending on whether you want d, h, m, s, instead of the full words.
relativeHours: the number of hours you want to be relative before it starts displaying the exact time.
relativeDays: the number of dates you want to be relative before it starts displaying the exact date.


Where

https://greasyfork.org/en/scripts/371251-wanikani-forums-detailed-timestamps

I’m open to suggestions if you think anything should be changed.

16 Likes

Suggestion for change: all posts older than 41 seconds should display “42+ seconds ago”

17 Likes

You mean literally all posts, don’t you? Not just posts between 41 and 60 seconds old? d3Ch

5 Likes

Kumirei may be the the hero this forum needs, but you’re the one it deserves.

18 Likes

Chaos is my middle name.

7 Likes

Setting for format of Dec 6, 2015?

2 Likes

You’re right, it makes more sense to do it that way, since I do MM DD hh:mm before that. I’ll just make that the default.

@seanblue While you’re here can I ask your opinion on making it 2 hours 40 minutes instead of 2h 40m ago. The latter doesn’t really fit in with the other formats.

2 Likes

Honestly I’d just use h, m, and s everywhere that isn’t using a full timestamp. Also, you should use or not use “ago” consistently for all of the non-timestamp versions (I have no preference which way).

P.S. I was “here” as in typing furiously while at a red light.

2 Likes

This will save lives
And the lives of threads

2 Likes

Added short format (h, m, s) as an option and made it default. I made it default because that’s how it’s done natively.

@seanblue How do you feel about the relative dates? Would you prefer “Today 06:55” and “Yesterday 16:15” to be shortened to “06:55” and “1d ago at 16:15”, or something similar?

2 Likes

I don’t really have a preference on that.

2 Likes

Current formatting:

With the first 4 hours being relative time, and the first 7 days being relative dates; let’s assume a post was posted 6:55 AM August 16, 2016.

Time since post Forum Default Short Format 12h Short Format 24h Long Format 12h Long Format 24h
30 seconds 1m 30s 30s 30 seconds 30 seconds
5 minutes 5m 5m 5m 5 minutes 5 minutes
1h 10m 1h 1h 10m 1h 10m 1 hour 10 minutes 1 hour 10 minutes
3h 31m 4h 3h 31m 3h 31m 3 hours 31 minutes 3 hours 31 minutes
4h 50m 5h 6:55 AM 06:55 Today at 6:55 AM Today at 06:55
1d 1h 1d 1d, 6:55 AM 1d, 06:55 Yesterday at 6:55 AM Yesterday at 06:55
2d 3h 2d 2d, 6:55 AM 2d, 06:55 2 days, 6:55 AM 2 days, 06:55
8d 8d Aug 16 6:55 AM Aug 16 06:55 Aug 16 6:55 AM Aug 16 06:55
2 months Aug 16 Aug 16 6:55 AM Aug 16 06:55 Aug 16 6:55 AM Aug 16 06:55
1 year Aug '16 Aug 16, 2016 Aug 16, 2016 Aug 16, 2016 Aug 16, 2016
2 Likes

@Kumirei Any reason you can’t have the relativeDays setting as high as 30? I want to mimic the forum defaults by using 24 hours and 30 days.

Nope, I believe that should work just fine

Well these are my current settings:

const AmPmTime = false;
const shortFormat = true;
const relativeHours = 24;
const relativeDays = 30;

And here’s why I see for your most recent post:


EDIT: It seems to break as soon as I change relativeDays to 16 or larger.

I see the issue, I’ll fix it right away


edit: @seanblue alright try now

1 Like

I’m in bed now (no computer), but I’ll try tomorrow. :slight_smile:

Do you think it makes sense to make 30 days / 24 hours the default settings? By doing that, all the defaults would match the forum’s actual defaults. So your script (by default) would just make the times more precise and better formatted.

Yeah, that makes sense. I should have done that but it started as something that I made for myself so my numbers stuck I’ll make that the default.

1 Like

@Kumirei It’s a little weird having the time just tick up every second for new posts. I’d recommend scrapping the seconds display and changing it to < 1m in short format and < 1 minute in long format. Plus, then you’d only have to have the code update the UI once a minute.

Alright, will do. Wasn’t sure about that anyway.

You think it’s a big deal to update one element every second for one minute?

1 Like