mirror of
https://github.com/fail2ban/fail2ban.git
synced 2026-03-11 08:55:31 +00:00
TST: add datetime method on mytime for rework of datedetector
This commit is contained in:
parent
d875e8ca0d
commit
4997b30193
1 changed files with 9 additions and 1 deletions
|
|
@ -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 a new issue