debrief / debrief

The Open Source workbench for Maritime Analysis
http://www.debrief.info
Eclipse Public License 1.0
25 stars 25 forks source link

TimeZone troubles for time in Maintain Contributions view #595

Closed pecko closed 10 years ago

pecko commented 10 years ago

[Migrated from Assembla ticket 597 - reported by @IanMayo on 2014-05-15 14:09:02]

Just installed new release on user system, but noticed problem in Maintain Contributions View.

I added a straight leg, but the start/stop times displayed were 1 hour too late. So, I selected data from, say 0602 to 0623 and selected "Create Straight Leg from sensor cuts". But, in the Maintain Contributions view, the start and stop times were shown as 0702 to 0723.

I'm sure this is because the DateTime control is converting the values to Daylight Savings Time (+1 hour).

I don't suffer the problem in my Ubuntu machine. The users were using 32 bit Java on a 64 bit Windows 7 machine.

Would you mind trying to reproduce the problem on a MS Windows machine? If you can reproduce it, we can confidently fix it.

From previous experience, I do have to force SWT controls to use a Calendar that is set to GMT. See around line 137 of org.mwc.cmap.grideditor.table.DateTimeCellEditor

But, it doesn't look like it is possible to override the Calendar object within the DateAndTimeObservableValue eclipse control.

h1. Possible steps to reproduce

pecko commented 10 years ago

[Migrated from comment on Assembla ticket 597 - comment by @pecko on 2014-05-15 14:11:48]

Checking ...

pecko commented 10 years ago

[Migrated from comment on Assembla ticket 597 - comment by @pecko on 2014-05-15 15:15:24]

I can reproduce the issue even on Linux. It looks that it depends on local timezone. My timezone is CEST (GMT+2); I guess that your timezone is BST (GMT+1). Seems that the Maintain Contributions view assume the BST zone and set time in BST. I think that we should convert it in GMT+0 always. Right?

pecko commented 10 years ago

[Migrated from comment on Assembla ticket 597 - comment by @IanMayo on 2014-05-15 15:22:41]

Yes, I'm BST.

Yes, we should force Maintain Controibtions view to GMT + 0. Please...

pecko commented 10 years ago

[Migrated from comment on Assembla ticket 597 - comment by @pecko on 2014-05-15 15:23:49]

Have to find where the time is converted. Checking ...

pecko commented 10 years ago

[Migrated from comment on Assembla ticket 597 - comment by @pecko on 2014-05-15 21:10:38]

Seems that the XStream framework converts only Daylight Savings Time. You are BST (raw offset=0, dst=+1hour) and it works fine for you. I'm CEST (raw offset=+1hour, dst=+1hour) and I get time+1 hour (as you described in test case)

I have fixed by adding specific DateConverter that adds raw offset. The PR: https://bitbucket.org/ianmayo/debrief/pull-request/90/issue-597-timezone-troubles-for-time-in

BTW Debrief uses xtream 1.1.3 in the o.m.cmap.core plugin and xtream 1.4.4 in the o.m.debrief.satc.core plugin. We should probably create a separate xtream plugin (similar as we create o.m.cmap.jfreechart library).

pecko commented 10 years ago

[Migrated from comment on Assembla ticket 597 - comment by @pecko on 2014-05-15 22:25:41]

You can change timezone in JVM by adding -Duser.timezone= to VM arguments tab or in DebriefNG.ini For instance,

-Duser.timezone="Europe/Belgrade" - my zone -Duser.timezone="Europe/London" - your zone

pecko commented 10 years ago

[Migrated from comment on Assembla ticket 597 - comment by @IanMayo on 2014-05-16 07:49:29]

Peco, thanks for all that investigating.

Do both steps need to be followed? - apply the PR and change the VM arguments?

If that's the case then I've a different recommendation. I would like to force the timezone to be GMT for all users. So, if the data-file says "06:00:00" then then time displayed will be "06:00:00" for all users, where-ever they are. Can the PR be modified to do this?

pecko commented 10 years ago

[Migrated from comment on Assembla ticket 597 - comment by @pecko on 2014-05-16 11:46:03]

Do both steps need to be followed? - apply the PR and change the VM arguments?

The PR is enough. I have mentioned the VM arguments only in order to test the PR locally.

If that's the case then I've a different recommendation. I would like to force the timezone to be GMT for all users. So, if the data-file says "06:00:00" then then time displayed will be "06:00:00" for all users, where-ever they are. Can the PR be modified to do this?

We can do it. We can add the VM argument (-Duser.timezone=GMT) within the Debrief product file. It would be logically since the Debrief writes all times in GMT (UTC) without converting timezone. Only the issue could be when using current time (for instance, when creating a new track): the user will get current time in GMT, but not in its timezone. On the another hand, the time will be saved in GMT, so it is correctly.

pecko commented 10 years ago

[Migrated from comment on Assembla ticket 597 - comment by @pecko on 2014-05-16 16:03:43]

While I creating the PR to add the "-Duser.timezone=GMT" VM argument, I notice that some libraries used in the satc.core plugin aren't added to build (common-io, for instance). It causes that the thirty_min_earlier_first_turn.xml plot isn't opened properly ("Straight leg forecast - first leg B" is missing). I have created a two new PRs:

You can apply some of these three (including previous PR) or only some of them. The PRs are independent. IMO, we would apply all of them if the issue with timezone (current time) is acceptable for you.

pecko commented 10 years ago

[Migrated from comment on Assembla ticket 597 - comment by @IanMayo on 2014-05-16 16:04:41]

Sure, will inspect and merge on Monday. Cheers, Ian

pecko commented 10 years ago

[Migrated from comment on Assembla ticket 597 - comment by @pecko on 2014-05-16 16:07:03]

Great. I will play with #24.

IanMayo commented 10 years ago

Issue resolved in Peco PR