mirror of https://github.com/fail2ban/fail2ban
TST: add datetime method on mytime for rework of datedetector
parent
d875e8ca0d
commit
4997b30193
|
@ -21,7 +21,7 @@ __author__ = "Cyril Jaquier"
|
|||
__copyright__ = "Copyright (c) 2004 Cyril Jaquier"
|
||||
__license__ = "GPL"
|
||||
|
||||
import time
|
||||
import time, datetime
|
||||
|
||||
##
|
||||
# MyTime class.
|
||||
|
@ -74,6 +74,14 @@ class MyTime:
|
|||
return time.gmtime(MyTime.myTime)
|
||||
gmtime = staticmethod(gmtime)
|
||||
|
||||
#@staticmethod
|
||||
def now():
|
||||
if MyTime.myTime is None:
|
||||
return datetime.now()
|
||||
else:
|
||||
return datetime.datetime.fromtimestamp(MyTime.myTime)
|
||||
now = staticmethod(now)
|
||||
|
||||
def localtime(x=None):
|
||||
if MyTime.myTime is None or x is not None:
|
||||
return time.localtime(x)
|
||||
|
|
Loading…
Reference in New Issue