Community Wishlist Survey 2023/Bots and gadgets/Allow client-side scripts to convert dates in the format used in MediaWiki interface/Proposal/en

From Meta, a Wikimedia project coordination wiki
  • Problem: Software, including MediaWiki APIs, usually handles dates in Unix time (e.g. 1672543856) or ISO format (2023-01-01T12:30:56Z), but MediaWiki shows them in human-friendly formats such as "04:30, 1 January 2023" or "2023年1月1日 (日) 20:30". But script developers have no access to the logic according to which these formats are produced (or even the difference between the user/site's time and UTC, which can vary with DST) and can't show dates in a way that is consistent with how the user sees the rest of the MediaWiki interface.
  • Proposed solution: Expose the server-side logic for formatting dates for each language/format through an API and develop a JavaScript library, perhaps as an extension to mw.language, that can convert a date in the format set by the site or user (and preferably vice versa).
  • Who would benefit: Users and developers of MediaWiki and its extensions, gadgets and scripts
  • More comments: PageTriage even replaced JavaScript's native Date object, which obviously ran into problems, so now it uses the Moment library, which is also to be replaced. Even then you can't account for every one of the numerous ways users see the MediaWiki interface without an unreasonable amount of reinventing the wheel, because various users, sites and languages use not only different timezones but different numerals, eras and calendars.
  • Phabricator tickets: T21992
  • Proposer: Nardog (talk) 06:51, 6 February 2023 (UTC)[reply]