__author__ = 'root'
from datetime import *
TIMEFORAT = "%Y-%m-%d %H:%M:%S"
class CTimeHandle():
def __init__(self, timeformat=TIMEFORAT):
self._format = timeformat
self._year = ""
self._datetime = datetime.now()
def diffTwoTimeSeconds(self,time1,time2,format=TIMEFORAT):
datetime1 = datetime.strptime(time1,format)
datetime2 = datetime.strptime(time2,format)
k=1
if self.CompareTwoTime(time1,time2,format):
temp = datetime1
datetime1 = datetime2
datetime2 = temp
k=-1
diff = (datetime1 - datetime2).seconds
result = int(diff)*k
print result
return result
def CompareTwoTime(self,time1,time2,format=TIMEFORAT):
datetime1 = datetime.strptime(time1,format)
datetime2 = datetime.strptime(time2,format)
return datetime1