vdstatus/plugins/date.py

17 lines
506 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, config):
defaults = {'format': '%c', 'tz': None}
super(PluginThread, self).__init__(config, defaults)
self.timezone = None
if self.conf['tz']:
import pytz
self.timezone = pytz.timezone(self.conf['tz'])
2016-10-22 19:27:28 +03:00
def main(self):
now = datetime.datetime.now(tz=self.timezone)
self.status['full_text'] = now.strftime(self.conf['format'])