00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 import time
00018 from objects.logic.common.logger import logger
00019
00020
00021
00022
00023 class timeUtil():
00024 def __init__(self):
00025 pass
00026
00027
00028
00029
00030 def formatTime(t):
00031 try:
00032 fmt = time.localtime(t)
00033 except Exception, e:
00034 logger.log(__name__ + ": Could not construct time object from input")
00035 return ""
00036
00037 return time.strftime("%H:%M:%S", fmt)
00038
00039
00040
00041
00042
00043 def formatTimeDiff(t):
00044 Hrs = int(t / 3600)
00045
00046 remainder = t % 3600
00047
00048 Min = int(remainder/60)
00049
00050 remainder = t % 60
00051
00052 Secs = int(remainder)
00053
00054 retString = "%d Hrs %d Min %d Sec" % (Hrs, Min, Secs)
00055 return retString
00056
00057
00058
00059
00060
00061
00062 def formatDateTime(t):
00063 try:
00064 fmt = time.localtime(t)
00065 except Exception, e:
00066 logger.log(__name__ + ": Could not contruct time object from input")
00067 return ""
00068
00069 return time.strftime("%m/%d/%y %H:%M:%S", fmt)
00070
00071
00072
00073
00074
00075 formatTime = staticmethod(formatTime)
00076 formatTimeDiff = staticmethod(formatTimeDiff)
00077 formatDateTime = staticmethod(formatDateTime)
00078