jazzband / Watson

:watch: A wonderful CLI to track your time!
http://tailordev.github.io/Watson/
MIT License
2.46k stars 240 forks source link

Times are always shown in UTC despite different local timezone configured on system #501

Closed sh-at-cs closed 1 year ago

sh-at-cs commented 1 year ago

I'm using this on Ubuntu 22.04 with my local timezone set to CEST:

$ date
Mo 8. Mai 18:13:43 CEST 2023

Nonetheless, all times printed by watson log are shown in UTC (without saying that that's what it is, which makes it even more confusing, but that's a separate issue). I think this is a bug because anyone would reasonably expect human-readable times output by a tool like this to be in local time.

What's even weirder is that times manually added via watson add are understood to be in local time, as evidenced by being shifted by UTC-CEST from their numeric input values in the log output. So it's really just the output that's the issue.

Related (but not the same because it's asking for anything other than local time to be possible): #391

Version info

$ watson --version
Watson, version 2.1.0
ericguirbal commented 1 year ago

I use the same version on a Debian box with the same timezone, and it works well. Can you show the output of the command timedatectl ? A workaround can be to set the TZ variable (if it is not already set); you can make a test with something like TZ="Europe/Paris" watson log.

sh-at-cs commented 1 year ago

The TZ="Europe/Paris" workaround works, thank you!

Here is my timedatectl output:

$ timedatectl
               Local time: Mo 2023-05-08 20:44:48 CEST
           Universal time: Mo 2023-05-08 18:44:48 UTC
                 RTC time: Mo 2023-05-08 18:44:48
                Time zone: Europe/Berlin (CEST, +0200)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

It seems like an issue with my Python installation, because datetime.now's docs say

Return the current local date and time.

but on my system it seems to be UTC anyway:

>>> from datetime import datetime
>>> print(datetime.now())  # actual local time is 20:53
2023-05-08 18:53:05.174651

This doesn't happen if I use a Python version installed via pyenv instead of the Brew-provided version (no idea why I started using that one anyway).

So I'll close this as it seems to be an issue on my end. Thanks for the help!