vdstatus/plugins/date.py

21 lines
559 B
Python
Raw Normal View History

import datetime
import plugins
2016-10-18 20:00:43 +03:00
DATE_DEFAULTS = {'format': '%c'}
class PluginThread(plugins.PluginThreadCommon):
def __init__(self, config):
super(PluginThread, self).__init__(config, DATE_DEFAULTS)
self.timezone = None
if 'tz' in self.conf:
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)\
.strftime(self.conf['format'])
self.format_status(now)