Added a new formatTime function to common, and replaced similar functions in other classes

This commit is contained in:
Veronica K. B. Olsen
2020-10-23 20:26:29 +02:00
parent 78a0a595b9
commit 170c2dc19c
4 changed files with 43 additions and 33 deletions
+10
View File
@@ -169,6 +169,16 @@ def formatTimeStamp(theTime, fileSafe=False):
else:
return datetime.fromtimestamp(theTime).strftime(nwConst.tStampFmt)
def formatTime(tS):
"""Format the time spent in 00:00:00 format.
"""
if isinstance(tS, int):
if tS >= 86400:
return f"{tS//86400:d}-{tS//3600%24:02d}:{tS%3600//60:02d}:{tS%60:02d}"
else:
return f"{tS//3600:02d}:{tS%3600//60:02d}:{tS%60:02d}"
return "ERROR"
def splitVersionNumber(vString):
""" Splits a version string on the form aa.bb.cc into major, minor
and patch, and computes an integer value aabbcc.