Currently on the frontend, mw.user.options.get('timecorrection') gives the time zone from the user's site preferences, but this timezone can't be reliably used as it doesn't take into account changes due to DST. See explanantion by @JJMC89 at T223002#5843155.
Exposing the correct timezone offset (maybe via an mw.config property) would make it possible for client-side JS to accurately format dates and times per user preferences. The absence of this feature is affecting a number of tools:
- Navigation-Popups-Gadget: Times displayed become off by 1 hour every year whenever the DST season starts and ends. T223002 This bug has been reported many times starting from 2012/2013 but still remains unresolved.
- Convenient-Discussions: also suffers from similar timezone issues (https://github.com/jwbth/convenient-discussions/pull/24#issuecomment-812235772)
- Twinkle: Its library function for formatting dates is capable of doing it in UTC and in user's system timezone. The option to format them in user time zone is conspicuously absent because due to this DST issue. (https://github.com/wikimedia-gadgets/twinkle/pull/814#issuecomment-585233657)
Possible solutions:
- mw.config.get('timezone') could give the DST-corrected timezone. This is computed on the server side for every page with dates, so would likely cost nothing for it to be exported, except for a tiny bit of HTML load.
- ApiQueryUserInfo could add timezone as a new uiprop option. Looks like getCurrentUserInfo() is where the changes needs to be made.