From ea7efb66c2e845f37382ce3cf1d92fe6efc1f0cb Mon Sep 17 00:00:00 2001 From: Henok Biadglign Ademtew <46082799+HenokB@users.noreply.github.com> Date: Mon, 4 Oct 2021 03:07:17 -0400 Subject: [PATCH] Time Delta --- Hackerank/Python/Time Delta.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Hackerank/Python/Time Delta.py diff --git a/Hackerank/Python/Time Delta.py b/Hackerank/Python/Time Delta.py new file mode 100644 index 000000000..a65a18630 --- /dev/null +++ b/Hackerank/Python/Time Delta.py @@ -0,0 +1,29 @@ +#!/bin/python3 + +import math +import os +import random +import re +import sys +from datetime import datetime + +def time_delta(t1, t2): + t1 = datetime.strptime(t1, '%a %d %b %Y %H:%M:%S %z') + t2 = datetime.strptime(t2, '%a %d %b %Y %H:%M:%S %z') + return str(int(abs((t1-t2).total_seconds()))) + +if __name__ == '__main__': + fptr = open(os.environ['OUTPUT_PATH'], 'w') + + t = int(input()) + + for t_itr in range(t): + t1 = input() + + t2 = input() + + delta = time_delta(t1, t2) + + fptr.write(delta + '\n') + + fptr.close()