We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
importmathimportosimportrandomimportreimportsysfromdatetimeimportdate,time,datetimedeftime_delta(t1,t2):# Define the datetime formatdate_format="%a %d %b %Y %H:%M:%S %z"# Convert the datetime strings to datetime objectsdt1=datetime.strptime(t1,date_format)dt2=datetime.strptime(t2,date_format)# Calculate the difference in secondsdelta_seconds=int(abs(dt1-dt2).total_seconds())# # Return the difference as a stringreturnstr(delta_seconds)if__name__=='__main__':fptr=open(os.environ['OUTPUT_PATH'],'w')t=int(input())fort_itrinrange(t):t1=input()t2=input()delta=time_delta(t1,t2)fptr.write(delta+'\n')fptr.close()
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Time Delta
You are viewing a single comment's thread. Return to all comments →