Datatables: Date has a 1-day difference when client is in another timezone #34

Open
formwandler opened this Issue Apr 23, 2014 · 6 comments

Projects

None yet

5 participants

@formwandler

We have a SMW + SRF wiki which runs in CET timezone (set in Linux OS, PHP and wiki). We have a semantic property from type "Date". When setting this property to a value like "2014/03/19" (either in source code, by using SF or with datepicker), the datatables format shows "19 March 2014" when I view the table in my clients timezone, which is also CET. So far, so good.

But: We have users in timezone EST. When they view the result of the inline query as "datatables" format, they see a date of "18 March 2014". So, there is a gap of one day. When switching to e.g. "broadtable", the date is ok with "19 March 2014".

So, this is definitively a "datatables" problem, maybe as a combination of timezones set on server/client. I don't know yet.

When I change my timezone in the wiki preferences to EST or even GMT-08, the resulting "datatable" output is ok with "19 March 2014".

However, the EST-user checked it on another local EST-client. The 1-day difference could be reproduced there.

I don't know how to "simulate" this problem on my side. I always see the right date in the output. I don't have a public wiki in place to show the issue, but could setup something if needed.

Is there anything I could check or set regarding Manual:Timezone?

@formwandler

Here is some additional info about the timezone settings of the client (both, Linux and Windows resulting in the same problem):

Linux is set to "Region: America, City: New York" in the "Date and Time" settings.
% date
ons 23 apr+ 2014 07.11.+09 EDT
% echo $LC_TIME
sv_SE.UTF-8

Windows is set to "(UTC-05:00) Eastern Time (US & Canada)"

The "Data and time" preferences in the wiki were set to offset and also to CET, both resulting in having the problem.

@darenwelsh

We just happened to stumble upon this bug. We noticed that for pages with a property of type Date associated, that value is incorrectly displayed if the datatables format is used. The value is off by -1 day. So if the date should be 15 April 2016, it shows 14 April 2016.

I tried updating my preferences in Mediawiki to specify my local time zone and this seemed to have no effect.

@JeroenDeDauw JeroenDeDauw added the bug label May 22, 2016
@JeroenDeDauw
Member

Oh no - we don't want NASA to accidentally launch a rocket a day too late!

@kghbln
Member
kghbln commented Jun 2, 2016

I am not so much worried about the rockets NASA is launching. I would be about the ones the DoD may launch but apparently they are not quite ready to use SMW in connection with this purpose. At my fathers former work place they still have an IBM 5285, no longer in active use though. I only used it a couple of times. but this hardware still had a soul.

@JeroenDeDauw
Member

Huh? SMW can't run on floppy disks? Why not? If that is true, we really ought to mention that in the compatibility docs.

@Rikeus
Rikeus commented Jul 7, 2016 edited

I've traced the -1 day bug. The formats/datatables/resources/ext.srf.formats.datatables.js file calls getMediaWikiDate() (line 182) which is within the SemanticMediaWiki file ext.smw.dataItem.time.js

For some reason, the calculated date is a day off and displays as such using the datatables format. Changing line 38 of ext.smw.dataItem.time.js to this.date = new Date( (this.timestamp + 86400) * 1000); and line 42 to this.date = new Date( (parseFloat( this.timestamp ) + 86400) * 1000); fixes the -1 day issue. This doesn't fix the heart of the problem, but rather forces all displayed dates (which are a day off) to be correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment