Page MenuHomePhabricator

Implement mw.Time module for parsing, formatting and "timeago" display of timestamps
Closed, ResolvedPublic

Description

Initial attempt in I9f9ca62f0744f0a.

Recommending to integrate http://momentjs.com/ instead.

Via a subclass of module, one could integrate the localisation between mw and momentjs.


Version: 1.18.x
Severity: enhancement

Details

Reference
bz45834

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:26 AM
bzimport set Reference to bz45834.
bzimport added a subscriber: Unknown Object (MLST).

Krinkle: Would that fix bug 30857?

Change 95555 merged by Krinkle:
Add Moment.js library for working with date and time

https://gerrit.wikimedia.org/r/95555

I'm marking this as closed (though Krinkle didn't merge it, I did) - we now have a library, and an extension (MultimediaViewer) is already using it. I call that a success.

Until ca. yesterday this code has worked moment.format('YYYY-M-D') but yet not anymore.

Ok it works if the MultimediaViewer is loaded. Could be there a documentation how to load this library / extension explicit!?

Have you added the module "moment" as a dependency to your script/gadget? That seems to be the ResourceLoader module associated to the files where this function is defined:
https://gerrit.wikimedia.org/r/#/c/95555/3/resources/Resources.php,unified
https://gerrit.wikimedia.org/r/#/c/95555/3/resources/moment/moment.js,unified

If it is a user script, you can use something like
mw.loader.using( 'moment', function(){

// ...
moment.format('YYYY-M-D')
// ...

} )
as documented on
https://www.mediawiki.org/w/index.php?title=ResourceLoader/Default_modules#mw.loader.using

(In reply to Helder from comment #6)
No and thx for clarification, it work now with the module load and moment().format('YYYY-M-D')
-> solved