2023-02-28

MediaWiki Display Historic Date/Time In User's Local Time

Presently, I've installed MediaWiki on a wiki which includes a section with a timeline of modern historic events in basically every article. It's important to display the precise time of day of these global historic events in a meaningful way and I anticipated this would be easy to accomplish.

Presently, I am converting timestamps of events into my current local time and typing them as plain text in the article when I make edits. This works great for me, but most other users of the wiki will be in different timezones and I'd rather not arbitrarily declare my local timezone as the "ultimate source of global truth" and force everyone else around the world to convert all times to my local timezone.

Similarly, I could convert all the times to UTC but, in fact, the majority of users I anticipate won't be from Europe. I could use Eastern time, but honestly, many of the timelines concern events that have happened in Asia, Australia, and other places globally. It's very frustrating for me to try to mentally convert times that are in UTC all the time if I'm trying to understand an series of historical events, and I don't want to have to put anyone else through that anguish.

What I'd like is a simple markup to automatically display a fixed point in time (ideally accepted as either a timestamp or date including a timezone) in the user's local time. That is, (1) the timezone of their browser if it can be determined, (2) the timezone they set in "Time zone" under "Appearance", or (3) the default timezone of the wiki only as a fallback. The best solution would be one that appears on the Visual Editor and allows the user to easily insert a date/time without having to necessarily go to the source editor level. It would be a really cool feature if above the timeline I could even stick a drop down so the user could see the events represented in different timezones as they are playing out globally, but I'm very happy with just the basics.

Here are the various ways I've tried to solve this problem so far that haven't worked:

(1) Dynamic dates or Date formatting and linking Apparently this was removed in MediaWiki 1.21. I'm not sure that it is exactly what I'm looking for anyway.

(2) Magic words. All of these apparently display in UTC only. They also only display the current time and not past historic points in time.

(3) MediaWiki's #time function in the ParserFunctions extension. ParserFunctions actually came pre-installed and just had to be enabled. Unfortunately, all the times are still displayed in UTC no matter what, subjecting all users who don't live in a thin strip of Europe and Africa (including me) to "endless anguish" as above.

(4) MediaWiki's #timel function in the ParserFunctions extension. I got excited briefly before I realized the dates are still only displayed in a single timezone. I can change the timezone using $wgLocaltimezone in LocalSettings.php but that's only changing it globally for the whole wiki. If a user views the wiki or logs in from Europe or Asia or Australia, all the times will not make much sense to them and they will be subjected to "endless anguish". Another less severe but still notable issue is that these time instructions appear to only be able to be inserted by manually editing the source code, and there isn't any option in the Visual Editor.

(5) The StringFunctions extension also has some time processing capabilities. Unfortunately it's just an older version of the ParserFunctions extension and obsolete.

(6) I found something called Semantic MediaWiki which is apparently an extension that supports a "Type_Date" structure, which "is used for data values that represent points in time". However, even if I wanted to install that entire extension just for this simple task, it unfortunately says "[u]ser settings are not taken into account for displaying dates."

(7) Date formatting and linking or Template:Date. I can't find any articles here on Stack Overflow that will help me either. At this point, I'm just flailing around basically.

Is there any way to get functionality like this to work on MediaWiki or is the only solution to develop some sort of simple plug-in (and how would I have to do that)? This doesn't seem like it should be that complicated of a thing to do/accommodate and I'm hoping there's a simpler solution I've overlooked. Thanks everyone for your help or ideas.



No comments:

Post a Comment