Fix #119
This commit is contained in:
parent
025d74555d
commit
5470d7460c
@ -4,7 +4,6 @@
|
|||||||
import os
|
import os
|
||||||
import locale
|
import locale
|
||||||
import datetime
|
import datetime
|
||||||
import pytz
|
|
||||||
|
|
||||||
from i3pystatus import IntervalModule
|
from i3pystatus import IntervalModule
|
||||||
|
|
||||||
@ -53,6 +52,10 @@ class Clock(IntervalModule):
|
|||||||
def run(self):
|
def run(self):
|
||||||
# Safest way is to work from utc and localize afterwards
|
# Safest way is to work from utc and localize afterwards
|
||||||
if self.format[self.current_format_id][1]:
|
if self.format[self.current_format_id][1]:
|
||||||
|
try:
|
||||||
|
import pytz
|
||||||
|
except ImportError as e:
|
||||||
|
raise RuntimeError("Need pytz for timezones") from e
|
||||||
utc_dt = pytz.utc.localize(datetime.datetime.utcnow())
|
utc_dt = pytz.utc.localize(datetime.datetime.utcnow())
|
||||||
tz = pytz.timezone(self.format[self.current_format_id][1])
|
tz = pytz.timezone(self.format[self.current_format_id][1])
|
||||||
dt = tz.normalize(utc_dt.astimezone(tz))
|
dt = tz.normalize(utc_dt.astimezone(tz))
|
||||||
|
Loading…
Reference in New Issue
Block a user