Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
convert timesheets to UTC with support for user timezone #372
Before this PR is/was merged Kimai stored datetimes in the local timezone. But this is a huge problem for various reasons (for technical backgrounds, please read this and this), so this PR changes the way how times are stored.
Before you start two advices:
This command can be safely executed if you did NOT import data from Kimai v1 before. This will convert ALL records in your database:
As Kimai 1 saved the times in another format, they were imported in UTC already, so they don't need conversion => they would be wrong if you convert them. So if you imported data from Kimai v1, you need to know the IDs that need to be converted. The command can take a start and an end ID.
Lets say you started with an import of 1000 records from Kimai 1, then the first ID that needs to be converted is 1001 which you append to the command like this:
If you want to convert the first 100 records, then skip the next 1000 and convert the rest, you need to execute two commands:
If you have question about the conversion, post a comment (even if the PR is closed already).
Sorry for the inconvience to everyone, this is why Kimai 2 is not yet released in a major version
blochwitz left a comment
If I checked out this branch and run
Do I have to restart something first (how?)?
# Conflicts: # public/build/manifest.json # src/Entity/Timesheet.php # src/Twig/DateExtensions.php # templates/admin/timesheet.html.twig # templates/timesheet/index.html.twig # tests/Twig/DateExtensionsTest.php # var/data/kimai_test.sqlite
I'm sorry it took some time to answer.
I did not convert anything, I started with an empty kimai. Checked out the timezone branch and tested. But I can see you did some work on this merged with master. So if the docker container is working again (after updating we encoutered lots of errors :(), we will test and come back to you. I'm sorry if that takes some time.
So the docker container works again.
We updated to the latest version. We did several things:
Whatever we do, when creating a new entry, start time is one hour early (UTC). Nothing changes when doing one of the changes above.
When going to the calender view of this week, there is a red stripe on the current day / time. That stripe is really the current local time for me. The red stripe doesn't change place when changing to Amsterdam or UTC.
So it looks like nothing is happening actually when changing the timezone. And then I am only looking at what happens when creating a new entry.
However, it is great we can now start activities in the future, so it is not a problem if you change the time to +1 hour. Not how it should be ;).
I created #554 for this.
Kimai uses the system time and converts it to UTC before saving. When reading from the DB it will convert it back to the timezone, which was used while recording (this can either be the PHP timezone or the users timezone - if you configured one).
Kimai does rely on the correct system time and correctly configured timezones. Sounds as if the docker container might be a source of your problem. Do you have a chance to test with the built-in PHP web server on your local machine (see dev installation docu)?
Upon executing the command
I checked and the PDO extension is installed for PHP:
What else could be wrong?