Page MenuHomePhabricator

Encourage maintainers of gadgets and user scripts to migrate away from the now-deprecated Moment library
Closed, ResolvedPublic

Description

Gadgets and user scripts using the moment library should revise their code to not use the library as it has been deprecated and will begin to log messages in the developer console.

Various alternatives exist including the Intl library and the new mediawiki.DateFormatter library. Please feel free to ask questions on this Phabricator ticket to get advice.

Impacted code:
https://global-search.toolforge.org/?q=%5B%22%5C%27%5Dmoment%5B%5C%27%22%5D&regex=1&namespaces=2%2C4%2C8&title=%28Gadgets-definition%7C.*%5C.%28js%7Ccss%7Cjson%29%29

Event Timeline

Tech News - @Jdlrobson, When should this be included? Please let me know if the wording below is in order. I will also need some links for this entry.

Moment library has been deprecated and will begin to log messages in the developer console. Gadgets and user scripts using the moment library should revise their code to other alternatives like Intl library and the new mediawiki.DateFormatter library.

2nd May! Wording looks good!

Jdforrester-WMF renamed this task from Moment library has been deprecated to Encourage maintainers of gadgets and user scripts to migrate away from the now-deprecated Moment library.Apr 23 2025, 9:43 PM

Fixed the task title to be what the work is.

2nd May! Wording looks good!

Thanks!

I've added it to https://meta.wikimedia.org/wiki/Tech/News/2025/19 with this wording; please advise (or edit directly) if changes are needed:

Developers who use the moment library in gadgets and user scripts should revise their code to use alternatives like the Intl library or the new mediawiki.DateFormatter library. The moment library has been deprecated and will begin to log messages in the developer console. You can see a global search for current uses, and ask related questions in phabricator.

I also recommend adding any useful links into the Task Description here, e.g. linking to any documentation about the mediawiki.DateFormatter library.

This was announced. Is there a reason to keep this ticket opened?

Quiddity claimed this task.

I’m looking at migrating my Comments in Local Time fork from Moment.js to Intl.RelativeTimeFormat and mediawiki.DateFormatter. Unfortunately, the user script currently relies on some behavior that the new libraries don’t cover: in Moment.js, calendar time can say “Last Monday”, whereas Intl.RelativeTimeFormat would say “5 days ago”. I’ll probably settle for just repeating the day of the week by itself, but this likely won’t be as understandable in some languages other than English. Just noting this in case other gadget or user script developers run into the same problem.