whois command + fix timeformatter for diff strubgs

This commit is contained in:
Stijn De Clercq 2020-10-23 19:33:01 +02:00
parent f6c324d656
commit f102faaf7e
4 changed files with 42 additions and 7 deletions

View file

@ -11,7 +11,7 @@ def epochToDate(epochTimeStamp, strFormat="%m/%d/%Y om %H:%M:%S"):
diff = now - updateTime
updateFormatted = str(updateTime.strftime(strFormat))
timeAgo = str(time.strftime('%H:%M:%S', time.gmtime(diff.total_seconds())))
return {"date": updateFormatted, "timeAgo": timeAgo}
return {"date": updateFormatted, "dateDT": updateTime, "timeAgo": timeAgo}
def dateTimeNow():
@ -51,8 +51,8 @@ def timeIn(seconds, unit):
# Creates a string representation based on Days/Hours/Minutes/Seconds
def diffDayBasisString(timestamp):
if isinstance(timestamp, int):
timestamp = datetime.datetime.fromtimestamp(timestamp)
now = datetime.datetime.fromtimestamp(time.time())
timestamp = epochToDate(timestamp)["dateDT"]
now = dateTimeNow()
diff = dateutil.relativedelta.relativedelta(now, timestamp)
timeList = []
@ -79,8 +79,8 @@ def diffDayBasisString(timestamp):
def diffYearBasisString(timestamp):
if isinstance(timestamp, int):
timestamp = datetime.datetime.fromtimestamp(timestamp)
now = datetime.datetime.fromtimestamp(time.time())
timestamp = epochToDate(timestamp)["dateDT"]
now = dateTimeNow()
diff = dateutil.relativedelta.relativedelta(now, timestamp)
timeList = []