'Clock' module only shows '?' now.
macxcool opened this issue · comments
Describe the bug
The 'clock' module only shows a question mark '?' no matter what I try. This has only happened in the last couple of days?
Your py3status version
py3status version 3.50 (python 3.11.3) on i3
To Reproduce
- Add module 'clock' to i3status config file
- It doesn't seem to matter how I configure the module. I haven't changed the config for years
- Run py3status
- The section of the i3bar where the clock module should be shows '?'
Expected behavior
The clock and time should show like normal.
Additional context
I'm running Archlinux and everything is up-to-date. Everything else in my py3status config seems to be working fine. I have the 'clock' stuff inside a 'frame' along with some other elements.
This seems to be caused by
py3status/py3status/modules/clock.py
Lines 191 to 195 in d27bb85
as ZoneInfo
seems to (no longer?) support "localtime".
Edit: In my case this is due to no longer having python tzdata installed (Arch Linux removed the package from the repositories). zoneinfo would fallback to that, and it provided the "localtime" key.
As a temporary fix you can specify your timezone directly in the config file:
clock {
format="{Europe/London}"
}
Perfect. That works for now. Thanks!
Specifying the timezone certainly works, but not having to specify would be better, especially for when travelling. I could get around it by changing the config to use the tztime
module (from i3bar I believe) instead of clock
.
I installed tzdata
from pip, but it didn't do anything, and if ZoneInfo
no longer supports "localtime" as an input, an alternative is to return None
as the Python docs imply that datetime.datetime.now(None)
returns local time. eg:
if tz == "Local":
return None
As no ZoneInfo
class is returned, None needs to be explicitly handled at:
https://github.com/ultrabug/py3status/blob/master/py3status/modules/clock.py#L254-L255
eg
if zone is None:
timezone = None
tzname = None
else:
timezone = zone.key
tzname = timezone.split("/")[-1].replace("_", " ")
Not very pretty in explicitly handling None
, and no idea of widespread impacts (it seems to work for me at the moment), but I'd be happy to submit a PR if the idea is suitable for the maintainers.
I'd be happy to submit a PR if the idea is suitable for the maintainers.
Go for it. Easier to review your code.
Thanks for your PR