vdstatus/plugins/date.py

19 lines
563 B
Python
Raw Normal View History

import datetime
import plugins
2016-10-18 20:00:43 +03:00
class PluginThread(plugins.PluginThreadCommon):
def __init__(self, section, config):
super(PluginThread, self).__init__(section, config)
2016-10-22 19:27:28 +03:00
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
2016-10-22 19:27:28 +03:00
def main(self):
now = datetime.datetime.now(tz=self.tz)
self.status['full_text'] = now.strftime(self.date_format)