2016-10-31 14:39:52 +01:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2016-10-30 17:30:09 +01:00
|
|
|
import datetime
|
2016-10-30 17:56:04 +01:00
|
|
|
import bumblebee.module
|
|
|
|
|
2016-10-31 16:08:03 +01:00
|
|
|
def usage():
|
|
|
|
module = __name__.split(".")[-1]
|
|
|
|
if module == "date":
|
|
|
|
return "date::<strftime format string, defaults to %x>"
|
|
|
|
if module == "time":
|
|
|
|
return "time::<strftime format string, defaults to %X>"
|
|
|
|
return "datetime::<strftime format string, defaults to '%x %X'>"
|
|
|
|
|
|
|
|
def notes():
|
|
|
|
return "none"
|
|
|
|
|
|
|
|
def description():
|
|
|
|
return "Displays the current time, using the optional format string as input for strftime."
|
|
|
|
|
2016-10-30 17:56:04 +01:00
|
|
|
class Module(bumblebee.module.Module):
|
2016-10-31 10:45:15 +01:00
|
|
|
def __init__(self, args):
|
2016-10-31 14:27:51 +01:00
|
|
|
super(Module, self).__init__(args)
|
|
|
|
|
2016-10-31 11:11:53 +01:00
|
|
|
module = self.__module__.split(".")[-1]
|
2016-10-31 14:39:52 +01:00
|
|
|
default = "%x %X"
|
|
|
|
if module == "date":
|
|
|
|
default = "%x"
|
|
|
|
if module == "time":
|
|
|
|
default = "%X"
|
2016-10-31 11:11:53 +01:00
|
|
|
|
|
|
|
self._fmt = args[0] if args else default
|
|
|
|
|
2016-10-30 17:30:09 +01:00
|
|
|
|
|
|
|
def data(self):
|
2016-10-31 10:53:31 +01:00
|
|
|
return datetime.datetime.now().strftime(self._fmt)
|
2016-10-30 17:30:09 +01:00
|
|
|
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|