jmpark0118 / CODING_TEST_PRACTICE

0 stars 0 forks source link

Practice>Python>Date and Time>Time Delta #87

Open jmpark0118 opened 3 years ago

jmpark0118 commented 3 years ago

image image

출처 : https://www.hackerrank.com/challenges/python-time-delta/problem

jmpark0118 commented 3 years ago

from datetime import datetime

def time_delta(t1, t2):
    time1 = datetime.strptime(t1, '%a %d %b %Y %H:%M:%S %z')
    time2 = datetime.strptime(t2, '%a %d %b %Y %H:%M:%S %z')
    return time1-time2

if __name__ == '__main__':
    t = int(input())

    for t_itr in range(t):
        t1 = input()
        t2 = input()

        delta = time_delta(t1, t2)

        print(int(abs(delta.total_seconds())))