-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fix timezone bug when clicking heatmap #15141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I don't think this is the right fix. This problem has several layers (I don't fully understand it, I hope I summarize correctly):
If I understand correctly, your changes would adress problem (3).. but it doesn't consider the browser timezone. Imho the correct fix would be to actually only store UTC timestamps in the DB (and convert already stored timestamps on activities to UTC via a migration). This is a longstanding issue with several proposed patches in the comments, did you take a look at this? #6087 |
I think it is really worth to do the work in #6087, but this pr and #13935 has nothing to do with #6087. #13935 just makes heatmap clickable, and passes "Date" parameter (converted to UTC time zone in frontend) to backend. |
To really fix all time zone issues, we need to:
Essentially the server must not be aware of a time zone and if client wants to send/display another time zone, they need to convert from/to UTC when talking with the server. The server can of course accept received ISO format with time zone info but needs to ensure it's converted to UTC before hitting the database. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I may have misunderstood the scope of this PR ;)
This fix seems to be a good stopgap for the issue, but to fix related issues like #6087 we should really only store UTC.
🚀 |
I click date block in heatmap, but gitea shows the actions in other date. There are two actions in 2021-03-23 00:10 (GMT+8) and 2021-03-23 00:21 (GMT+8), but only if I click 2021-03-22, the actions in 2021-03-23 would be displayed (see the below screenshot).

I enabled sql log, then and I find the query date range is 1616457600 (2021-03-23 08:00:00 in GMT+8) to 1616543999 (2021-03-24 07:59:59 in GMT+8) when I click "2021-03-23" in heatmap (see the below log). The time zone of the container which runs gitea is GMT+8. I runns the official docker image gitea/gitea:1.14.0-rc2.
You can reproduce this bug when the time zone of your server/container is not UTC.