Last modified: 2014-08-13 18:39:29 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T32857, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 30857 - Show more user-friendly timestamps (relative like "7 hours ago" instead of absolute)
Show more user-friendly timestamps (relative like "7 hours ago" instead of ab...
Status: NEW
Product: MediaWiki
Classification: Unclassified
History/Diffs (Other open bugs)
1.21.x
All All
: Low enhancement with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on: 19992 67959
Blocks:
  Show dependency treegraph
 
Reported: 2011-09-11 19:38 UTC by Sue Gardner
Modified: 2014-08-13 18:39 UTC (History)
16 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
How Facebook shows time and date (245.88 KB, image/png)
2011-09-11 19:38 UTC, Sue Gardner
Details

Description Sue Gardner 2011-09-11 19:38:38 UTC
Created attachment 9052 [details]
How Facebook shows time and date

When I'm looking at edit histories, I often find myself wanting to know roughly how long ago someone made an edit. Mostly because I am wondering if the person is still around to talk with.

But, it takes me a split second to do the mental processing, because MediaWiki just shows time and date. By contrast, when I'm on Facebook or Twitter or many other sites, that processing is automated for me, and I see human-friendly language like "7 minutes ago," "about an hour ago" or "17 days ago."

It probably makes sense for us to continue to show time and date, but I think it would be helpful to add a notation on the changes that have taken place within the past say eight hours, noting in human-friendly language how long ago the edit was made.

The purpose of this feature request is to eliminate a little mental processing on the part of editors, by automating it.
Comment 1 Brion Vibber 2011-09-15 00:49:18 UTC
Note that it can be helpful for such relative timestamps to also 'live update'; if the page is left open for some time, recent times should be able to recede from 'just now' to '5 minutes ago' to 'an hour ago' etc.

This will especially be important if this sort of thing gets implemented on future more ajax-y interfaces.

Adding bug 19992 as a dependency -- similar machine-readable markup for the timestamps would be needed to update them this way.


Visual clutter is also an issue -- short & sweet '3 years ago' is often handy, but checking exact times can be necessary for many wiki maintenance needs... but having both will just eat up more and more visual space.

I might suggest something like having a lot of markers default to showing the 'short' style, but allowing the user to switch the format live ... which of course brings its own new UI. :P :)   At least providing 'raw' times in a hover title would be super useful in many cases.
Comment 2 Yuvi Panda 2014-02-18 13:30:11 UTC
Now that moment.js has been implemented, this could be easier to do (for JS). I think a PHP solution already exists. We could identify areas where we should start doing this and go one by one?
Comment 3 Gerrit Notification Bot 2014-02-18 14:55:58 UTC
Change 113960 had a related patch set uploaded by Yuvipanda:
Show relative 'last modified at' at bottom of each page

https://gerrit.wikimedia.org/r/113960
Comment 4 Yuvi Panda 2014-02-18 14:57:05 UTC
Hmm, this might actually be terrible performance wise everywhere, since this renders pages uncacheable for anon users. I don't know how that would be fixed...
Comment 5 Andre Klapper 2014-02-18 15:11:29 UTC
(In reply to Yuvi Panda from comment #4)
> Hmm, this might actually be terrible performance wise everywhere, since this
> renders pages uncacheable for anon users. I don't know how that would be
> fixed...

CC'ing Ori, just in case he can comment performance-wise.
Comment 6 Yuvi Panda 2014-02-18 15:16:25 UTC
A more cache friendly solution would be to mark such timestamps with a class or other attribute and do the replacement in JS. While workable, this also has a (small?) performance penalty, and might also cause ugly 'flash'ing as things re-layout when a timestamp is changed for the first time.
Comment 7 Mark Holmquist 2014-02-18 18:10:50 UTC
FYI, https://gerrit.wikimedia.org/r/95555 was merged last night PST, and is now ready for use in core and extensions. PHP date/time may not be as easy, but at least JavaScript applications can be a little better about this now.
Comment 8 Mark Holmquist 2014-02-18 18:48:34 UTC
S informs me that CLDR supports this on the PHP side! All that's left is integrating it where necessary.

Maybe this should become a tracking bug for different instances of the issue, now that the grander architectural questions seem to be dealt with.
Comment 9 Mark Holmquist 2014-02-18 19:04:03 UTC
Sorry for missing the issue in comment 4. Maybe we could ignore cache invalidation, or maybe we could only ever return values that will last an hour, else return "less than 1 hour ago"? Ugly, but cacheable.

How does Reddit do this?
Comment 10 Matthew Flaschen 2014-02-18 19:16:02 UTC
If I recall correctly, anon HTML is cached for 30 days.  Perhaps it could just use the relative version for logged in users?
Comment 11 Yuvi Panda 2014-02-18 19:23:12 UTC
Yeah, was talking about this on IRC. Anon HTML is cached for 30 days unless explicitly invalidated, so even if we invalidate them only every day that's a 30x increase in invalidates and I don't think Ops will like us very much :)

We could show it only for logged in users, yes. Although that does feel a bit weird :)

The JS solution would work better if we top loaded the JS, of course :D We can also easily make it dynamic - updating it as time goes on, rather easily.
Comment 12 Gerrit Notification Bot 2014-02-18 19:28:52 UTC
Change 113960 abandoned by Yuvipanda:
Show relative 'last modified at' at bottom of each page

Reason:
See discussion on bug

https://gerrit.wikimedia.org/r/113960
Comment 13 Yuvi Panda 2014-02-18 19:35:29 UTC
Alright, so current 'consensus' seems to be:

1. Have PHP emit what it currently does, but add a data attribute with a machine readable timestamp and also a class or some such
2. Have JS (top loaded?) look for any element with the class added in (1), and then replace it with an appropriate relative time
3. Depending on how long ago the time is, we can use a setTimeout to make sure we keep updating it as time goes on, so that relative times are always correct

Open questions:

1. Can we top-load this JS? 
2. Can we top-load JS if we don't use jQuery?
3. Can we top-load JS if we just supported not-too-old browsers and did not use jQuery?
Comment 14 Yuvi Panda 2014-02-18 19:36:12 UTC
Also since this could potentially be top-loaded, is delivered to *all* anon users, and also modifies the DOM in place after it has loaded, I'd like a +1 from Ori for this approach before proceeding.
Comment 15 Bawolff (Brian Wolff) 2014-02-18 19:45:58 UTC
Keep in mind that some people might have usecases requiring absolute timestamps (e.g. copy and pasting a timestamp to a talk page). [Not saying dont do this, just saying to keep in mind that absolute ts is nice for some things too, when evaluating the solution]

Ideally i think it would be nice if this was somehow introduced as the (perhaps default) date preference, so people could choose.
Comment 16 Yuvi Panda 2014-02-18 20:04:18 UTC
Could, possibly. We could also have a title attribute show the absolute timestamp. I'd rather not have a separate date preference, but there's no reason we can't have one if a use case arises.
Comment 17 Yuvi Panda 2014-02-18 20:09:51 UTC
Also anons have no preferences :)
Comment 18 Bawolff (Brian Wolff) 2014-02-18 20:38:29 UTC
I meant use the existing date preference.
Comment 19 Matthew Flaschen 2014-02-19 01:26:47 UTC
(In reply to Yuvi Panda from comment #13)
> Open questions:
> 
> 1. Can we top-load this JS?

It certainly won't cause a problem to do this.  However, bear in mind this code can not run before ready, so even though it's top-loaded, it will run after all HTML has been delivered and parsed (and probably a few entries into the ready queue).

> 2. Can we top-load JS if we don't use jQuery?

Currently, absolutely all MediaWiki JavaScript requires jQuery.  The client-side part of ResourceLoader uses jQuery, which makes it a hard requirement.

Thus, there is an isCompatible function in the startup module; it's all or nothing.  Certain browsers are blacklisted from all ResourceLoader JS, but everything else gets both jQuery and the main MediaWiki module (which in turn loads other modules).

Can you explain the question a little further?
Comment 20 Isarra 2014-02-19 03:24:45 UTC
I hate to butt in like this, but do we have anything concrete to support that this is indeed more user-friendly, or necessarily even appropriate to mediawiki use cases?
Comment 21 Yuvi Panda 2014-02-19 07:23:44 UTC
(In reply to Matthew Flaschen from comment #19)
> It certainly won't cause a problem to do this.  However, bear in mind this
> code can not run before ready, so even though it's top-loaded, it will run
> after all HTML has been delivered and parsed (and probably a few entries
> into the ready queue).

Right, so there will still be a 'flash'

> > 2. Can we top-load JS if we don't use jQuery?

Oh, then it is just me being dumb :) Nevermind this question then.

THanks!
Comment 22 Ori Livneh 2014-02-19 09:08:01 UTC
(In reply to Isarra from comment #20)
> I hate to butt in like this, but do we have anything concrete to support
> that this is indeed more user-friendly, or necessarily even appropriate to
> mediawiki use cases?

What sort of evidence would qualify?
Comment 23 Bartosz Dziewoński 2014-02-19 16:06:34 UTC
Let me just note that we should keep the timestamp in the UI somewhere in addition to the relative date if we do this – this would be very relevant during, say, debugging with end-users or checkuser investigations.

I know of at least two sites that show timestamps on hover on the relative date (using the 'title' attribute) – Reddit and StackOverflow, we should probably do the same.
Comment 24 Yuvi Panda 2014-02-19 16:07:38 UTC
Indeed. Using title should be good enough, methinks.
Comment 25 Isarra 2014-02-19 18:17:10 UTC
(In reply to Ori Livneh from comment #22)
> (In reply to Isarra from comment #20)
> > I hate to butt in like this, but do we have anything concrete to support
> > that this is indeed more user-friendly, or necessarily even appropriate to
> > mediawiki use cases?
> 
> What sort of evidence would qualify?

Consideration of merits/drawbacks of each given common use cases, any relevant research (if it even exists), etc.
Comment 26 Matthew Flaschen 2014-07-19 00:29:02 UTC
(In reply to Yuvi Panda from comment #13)
> 2. Have JS (top loaded?) look for any element with the class added in (1),
> and then replace it with an appropriate relative time

A JavaScript library for generating such a relative time string in a consistent way would already be useful. (GettingStarted has a need for it for one of our experiments, for example).

MobileFrontend has custom code for displaying relative times.

momentjs is in core, and has fromNow (http://momentjs.com/docs/#/displaying/fromnow/).  If that suits our needs, we could standardize on that.  (If you follow that link, there is a table showing how it works).

Otherwise, I think we should pick an algorithm, put it in core, and use it consistently, including MobileFrontend.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links