Page MenuHomePhabricator

Timezone information on client side
Open, Needs TriagePublic

Description

The api returns everything in UTC times, instead of the timezone of the user.

The user however, will always want to be presented with local information... And to avoid confusion, we want to show that in the same zone as the user has configured (not necessarily the same as the browser).

I noticed that currently this is all handled rather adhoc.

  1. Revision slider mw.libs.revisionSlider.userOffset = mw.user.options.get( 'timecorrection' ) ? mw.user.options.get( 'timecorrection' ).split( '|' )[ 1 ] : mw.config.get( 'extRevisionSliderTimeOffset' );
  2. Navigation popups gadget fetches all the userthe user option with the api and then caches it in a cookie (because expensive)
  3. New page patrol, breaks normal API assumptions of return UTC timestamps and modified it's api results to take the user setting into account T45365: PageTriage uses server rather than local time

The proper way to do it right now, is likely to load the user.options module and then fetch 'timecorrection'. However, this module isn't even documented, but worse, it returns implementation details. The value is either in hours, or it's a string like: 'ZoneInfo|-240|America/New_York'

But we should make this consistent and easier to use for everyone.
Maybe add mw.user.getTimeCorrection(), which autoload user.options and parses it or something ?

Event Timeline

@Aklapper thx, exactly the type of problem that I referred to.

BTW i switched navigation popups to use something similar to revisionslider. The usage of cookies for a purpose like this is a tad deprecated anyways.

There's also a fourth way this is handled: use moment.js which uses the client's OS clock and timezone, ignoring the user's timezone preference. This is what Flow and Echo do, and people have complained about this (see the tasks that Andre linked above).