Repository: qtile/qtile

Issue:
python compatibility about timezone parameter for widget.Clock
# Issue description

The following widget configuration doesn't  work for python 3.8.2:
```
widget.Clock( format="%H:%M:%S", timezone="Asia/Taipei")
```

I made a workaround for this:
```
from dateutil.tz import *
widget.Clock( format="%H:%M:%S", timezone=gettz("Asia/Taipei"))
```

This error is related to the code snippets in `libqtile/widget/clock.py`:
```
    def poll(self):
        if self.timezone:
            now = datetime.now(timezone.utc).astimezone(self.timezone)
        else:
            now = datetime.now(timezone.utc).astimezone()
        return (now + self.DELTA).strftime(self.format)
```

It seems python 3.6+ has compatibility issue of timezone parameters, and native python doesn't support timezone locale like "Asia/Tokyo","Europe/Warsaw", ... or so. Currently I include `dateutil` to bypass the syntax error


# Qtile version
qtile 0.15.1-1 (ArchLinux)




Discussion:
This is actually just an undocumented qtile regression :). https://github.com/qtile/qtile/pull/1259#issuecomment-485476862
Did I really forget to put this in the changelog? If so, please slap me in the head with the largest trout available.
Out of curiosity, do you happen to have dateutil installed @matlinuxer2? I'll probably add it to the widget's supported libraries as it would restrict the pool of potentially affected users. And I'll update the changelog.

Edit: of course you have dateutil installed since you used it as a workaround, sorry for the useless ping and question!

Resolving patch:
diff --git a/libqtile/widget/clock.py b/libqtile/widget/clock.py
--- a/libqtile/widget/clock.py
+++ b/libqtile/widget/clock.py
@@ -33,6 +33,11 @@
 except ImportError:
     pass
 
+try:
+    import dateutil.tz
+except ImportError:
+    pass
+
 
 class Clock(base.InLoopPollText):
     """A simple but flexible text-based clock"""
@@ -41,9 +46,10 @@ class Clock(base.InLoopPollText):
         ('format', '%H:%M', 'A Python datetime format string'),
         ('update_interval', 1., 'Update interval for the clock'),
         ('timezone', None, 'The timezone to use for this clock, either as'
-         ' string if pytz is installed (e.g. "US/Central" or anything in'
-         ' /usr/share/zoneinfo), or as tzinfo (e.g. datetime.timezone.utc).'
-         ' None means the system local timezone and is the default.')
+         ' string if pytz or dateutil is installed (e.g. "US/Central" or'
+         ' anything in /usr/share/zoneinfo), or as tzinfo (e.g.'
+         ' datetime.timezone.utc). None means the system local timezone and is'
+         ' the default.')
     ]
     DELTA = timedelta(seconds=0.5)
 
@@ -53,10 +59,13 @@ def __init__(self, **config):
         if isinstance(self.timezone, str):
             if "pytz" in sys.modules:
                 self.timezone = pytz.timezone(self.timezone)
+            elif "dateutil" in sys.modules:
+                self.timezone = dateutil.tz.gettz(self.timezone)
             else:
                 logger.warning('Clock widget can not infer its timezone from a'
-                               ' string without the pytz library. Install pytz'
-                               ' or give it a datetime.tzinfo instance.')
+                               ' string without pytz or dateutil. Install one'
+                               ' of these libraries, or give it a'
+                               ' datetime.tzinfo instance.')
         if self.timezone is None:
             logger.info('Defaulting to the system local timezone.')
 


Test patch: