Provide user timezone metadata in xwiki-meta

Hi everyone,

I recently found a bug in LiveData which can only be fixed if we know the actual timezone of the current user (see Loading...). Technically it’s not an issue, but then @Oana-Lavinia_Florean told me that she had same need for a piece of javascript with Lightbox. And more generally we might have same need for any date manipulation in javascript.

So I’m thinking that it could be good to always have the info available in the DOM at a single place: hence the proposal to add that info in xwiki-meta and document it as part of https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/FrontendResources/JavaScriptAPI/#HGetsomeinformationaboutthecurrentdocument

The only thing that I find slightly annoying here is that right now it’s documented as being “Information about the current document” and here I want to put “Information about the current user”.

wdyt?

1 Like

xm.userReference is already not “Information about the current document”. The documentation should be updated to talk about context and not document.

That being said, there is something I’m wondering in the case of the timezone: wouldn’t it make more sense to rely on the browser’s timezone ? But maybe that will be the case in practice, and it’s sent with the GET request and end up in the xwiki context already ?

AFAICS we have more than just the current doc:

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" data-xwiki-paged-media="paper" data-xwiki-reference="xwiki:Main.WebHome" data-xwiki-document="Main.WebHome" data-xwiki-wiki="xwiki" data-xwiki-space="Main" data-xwiki-page="WebHome" data-xwiki-isnew="false" data-xwiki-version="17.1" data-xwiki-rest-url="/xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome" data-xwiki-locale="" data-xwiki-form-token="IT42x6GbT0aqXOMnI8Dg6Q" data-xwiki-user-reference="xwiki:XWiki.Admin" data-xwiki-page-ready="true"><head>

See for example data-xwiki-user-reference or data-xwiki-locale.

Or notify the user that the current (browser) timezone doesn’t match the timezone configured in the user profile, and let them chose which one to use (saving the choice in the local storage for instance).

Thanks,
Marius

Well even if we let them chose, then we need a value to rely on, so we could always rely on xwiki-meta API to get proper value. Feels like it’s more work to implement the notification to the user and everything, especially since the TZ of the user is currently not visible in users’ profile, it’s only in xobject editor. Which is probably a reason explaining the inconsistencies between what’s displayed to the user (computed by default using wiki TZ since that’s the fallback when user TZ is not defined) and the browser TZ.