ActivityWatch / activitywatch

The best free and open-source automated time tracker. Cross-platform, extensible, privacy-focused.
https://activitywatch.net/
Mozilla Public License 2.0
11.73k stars 533 forks source link

What is the proper way to change system time? / How does activity watch handle time conflicts? #853

Closed KarlRW closed 1 year ago

KarlRW commented 1 year ago

Question

I am on Windows 10. I need to change my system time back one hour. I am concerned that this will overwrite my previous hour of activity or cause some other issue.

  1. How will activity watch handle this (what will the timeline report look like for example)?
  2. Is there a safe way to do this?

Thanks for the great work!

github-actions[bot] commented 1 year ago

Hi there! As you're new to this repo, please make sure you've used an appropriate issue template and searched for duplicates (it helps us focus on actual development!). We'd also like to suggest that you read our contribution guidelines and our code of conduct. Thanks a bunch for opening your first issue! 🙏

ErikBjare commented 1 year ago

Simply changing timezones should be a non-issue, since we always store UTC time.

However, if you change your system time for another reason, like trying to trick some other application, it's likely to lead to several short events being interspersed in the past, as the events fail to merge. There should be log messages warning about what is happening ("new" events being older than the most recent event).

To be honest, I don't remember/am unsure what the behavior is in those cases. It's probably not good, and we should probably write tests for such scenarios, but it's likely to mess up things a tiny bit, but shouldn't be too bad.

You could always backup your database file, restart ActivityWatch, change your system time, inspect the data, and optionally restore the old database file (see docs for where the database file is located).

KarlRW commented 1 year ago

Thanks for the quick response. It worked flawlessly. The timeline shifted back one hour and I saw no issues in the logs.

activity_watch_before_and_after