codebrag icon indicating copy to clipboard operation
codebrag copied to clipboard

Bad timezone for date in browser

Open dreignier opened this issue 10 years ago • 6 comments

I have a codebrag on a CentOS in the CEST timezone. My browser is in the CEST timezone too. And the date of commits and comments are wrong (shift of 2 hours).

It's because when my browser receive the commits (for example), the json is like this :

{"commit":[{"id":"xxx","repoName":"xxx","sha":"xxx"
,"message":"correction code propre\n\naddresses #14895\n\ngit-svn-id: http://xxx/svn
xxx@38455 a77b0ce4-d186-493e-baf1-5dd2f1cda47c\n","authorName":"xxx","authorEmail"
:"xxx@xxx","date":"2015-10-05T10:27:33Z","state":"AwaitingUserReview"
,"authorAvatarUrl":"xxx","reviewers"
:[]}],"older":0,"newer":0}

As you can see, the date is 2015-10-05T10:27:33Z. But it is wrong. The correct date should be this date in the CEST timezone (so GMT +2 during summer). So the browser javascript just shift the date of 2 hours at displaying.

dreignier avatar Oct 05 '15 09:10 dreignier

Is there any workaround for this?

dstrimble avatar Apr 01 '16 21:04 dstrimble

I didn't find it yet sorry.

dreignier avatar Apr 02 '16 07:04 dreignier

I found a workaround, apparently the issue is when it's pulling the timestamp and inserting into the H2 database. I changed the server time to UTC and then reset the H2 database, after it did it's thing everything looked better.

dstrimble avatar Apr 02 '16 11:04 dstrimble

Thanks for tip. I'll try it.

dreignier avatar Apr 03 '16 10:04 dreignier

Yeah, the only workaround for now is to adjust server datetime. We don't translate time to user's timezone in browser as for now (but we probably should). I'll mark it as "to do" at some point, and as usual - PRs are welcome :)

mostr avatar Apr 05 '16 19:04 mostr

Seems like the issue is that it is converting them incorrectly on the transfer from git to H2 as it processes incoming commits. The proper solution would probably be to store them correctly in UTC time in the H2 database and then convert based on timezone in the browser.

dstrimble avatar Apr 05 '16 22:04 dstrimble