Skip to content
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

Times appear to be recorded in local timezone #132

Open
akaszynski opened this issue Jun 18, 2021 · 2 comments
Open

Times appear to be recorded in local timezone #132

akaszynski opened this issue Jun 18, 2021 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@akaszynski
Copy link

When changing timezones the results from timetrace list records today do not change. Times should be recorded in UTC and displayed relative to the current timezone.

@dominikbraun dominikbraun added enhancement New feature or request help wanted Extra attention is needed labels Jun 19, 2021
@dominikbraun
Copy link
Owner

dominikbraun commented Jun 19, 2021

Even though timetrace is still at v0.10.0, I'd like to maintain backwards-compatibility. So there are three options to switch to UTC:

  • Leave everything as it is and convert record timestamps to UTC when computing durations and displaying those timespamps.
  • Store everything in UTC in the future. When reading "legacy" records, detect whether they are UTC or not and convert them if necessary.
  • Introduce a configuration value for using UTC and assume UTC or not depending on that configuration. Maybe implement a migration command for converting old records to the currently configured time format.

@aligator PTAL

@aligator
Copy link
Collaborator

aligator commented Jun 22, 2021

I would say we should add an automatic conversion which is run the first time someone uses timetrace in the new version. (we can add something like a file with a version number somewhere in the .timetrace folder to indicate a new file-format.)

As I recently had a similar requirement at my daily work, I noticed some things to be aware of when using UTC in the "backend" and any localtime in the frontend:

  • It is always better to save data in UTC to have no problem when changing the timezone. Worst case: each value saved is in a different timezone...
  • different timezones may go through a daychange. So you have to adapt your loading logic to always also search for UTC-dates from the day before / after as e.g. if the client requests localtime today (with e.g. +2h timezone) you have to select for requested time (e.g. 0:00) -2h -> results in a requested time of yesterday 22:00 - today 22:00 UTC.
  • -> you always have to check the folders of the day before and after for times which are today in localtime.
  • -> when creating a converter from localtime to UTC, files may have to be moved to other record folders.

An additional suggestion:
When we are anyway in process of changing the file format:
Why don't we use a one-file database such as sqlite? It would have several benefits, such as

  • only one file to read
  • avoiding the issue of the other issue with the need to rename all files if the project name changes because then we can use a normal relational database design and do the rest through IDs
  • would avoid the need to read several folders because of the timezone issue noted above. We could then just compose a proper sql select which selects the time-dates needed for the current timezone.

--> Actually this is no easy task but we should change the saved values to UTC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants