mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-04-04 14:07:25 +00:00
add data['timestamp'] #72
to make sure, that all Plugins use the same timestamp
This commit is contained in:
parent
28936d68ec
commit
e7b5bffdd3
8 changed files with 38 additions and 17 deletions
|
|
@ -7,6 +7,7 @@ little Helper to get easy the curent date or time
|
|||
for direct use in plugins to save code
|
||||
|
||||
@author: Bastian Schroll
|
||||
@author: Jens Herrmann
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
|
@ -14,39 +15,55 @@ import logging
|
|||
import time
|
||||
|
||||
|
||||
def curtime(format="%d.%m.%Y %H:%M:%S"):
|
||||
def curtime(format="%d.%m.%Y %H:%M:%S", timestamp=""):
|
||||
"""
|
||||
Returns formated date and/or time
|
||||
see: https://docs.python.org/2/library/time.html#time.strftime
|
||||
|
||||
@type format: string
|
||||
@param format: Python time Format-String
|
||||
@type timestamp: floating point number
|
||||
@param timestamp: time in seconds since the epoch
|
||||
|
||||
@return: Formated Time and/or Date
|
||||
@exception: Exception if Error in format
|
||||
"""
|
||||
try:
|
||||
return time.strftime(format)
|
||||
if timestamp == "":
|
||||
return time.strftime(format)
|
||||
else:
|
||||
return time.strftime(format, time.gmtime(timestamp))
|
||||
except:
|
||||
logging.warning("error in time-format-string")
|
||||
logging.debug("error in time-format-string", exc_info=True)
|
||||
|
||||
|
||||
def getDateTime(timestamp=""):
|
||||
"""
|
||||
Returns the date and time
|
||||
|
||||
def getDate():
|
||||
@return: Formated date
|
||||
"""
|
||||
return curtime("%d.%m.%Y %H:%M:%S", timestamp)
|
||||
|
||||
|
||||
def getDate(timestamp=""):
|
||||
"""
|
||||
Returns the date
|
||||
|
||||
@return: Formated date
|
||||
"""
|
||||
return curtime("%d.%m.%Y")
|
||||
return curtime("%d.%m.%Y", timestamp)
|
||||
|
||||
def getTime():
|
||||
|
||||
def getTime(timestamp=""):
|
||||
"""
|
||||
Returns the time
|
||||
|
||||
@return: Formated time
|
||||
"""
|
||||
return curtime("%H:%M:%S")
|
||||
return curtime("%H:%M:%S", timestamp)
|
||||
|
||||
|
||||
def getTimestamp():
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ def replaceWildcards(text, data, lineBrakeAllowed=False):
|
|||
"""
|
||||
try:
|
||||
# replace date and time wildcards
|
||||
text = text.replace("%TIME%", timeHandler.getTime()).replace("%DATE%", timeHandler.getDate())
|
||||
text = text.replace("%TIME%", timeHandler.getTime(data["timestamp"])).replace("%DATE%", timeHandler.getDate(data["timestamp"]))
|
||||
|
||||
# replace some special chars
|
||||
if lineBrakeAllowed == True:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue