add pytz to the mix, so that we can display time for specific time zones (totally optional dependency)
This commit is contained in:
parent
e84936b3f8
commit
f5c49008ec
2 changed files with 12 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
|||
import time
|
||||
import datetime
|
||||
import plugins
|
||||
|
||||
|
||||
|
@ -6,6 +6,13 @@ class PluginThread(plugins.PluginThreadCommon):
|
|||
def __init__(self, section, config):
|
||||
super(PluginThread, self).__init__(section, config)
|
||||
self.date_format = config.get(section, 'format', fallback='%c')
|
||||
tz = config.get(section, 'TZ', fallback=None)
|
||||
if tz:
|
||||
import pytz
|
||||
self.tz = pytz.timezone(tz)
|
||||
else:
|
||||
self.tz = None
|
||||
|
||||
def main(self):
|
||||
self.status['full_text'] = time.strftime(self.date_format)
|
||||
now = datetime.datetime.now(tz=self.tz)
|
||||
self.status['full_text'] = now.strftime(self.date_format)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue