Sort by

recency

|

373 Discussions

|

  • + 0 comments

    Here's my code:

    from datetime import datetime
    def time_delta(t1, t2):
        df = '%a %d %b %Y %H:%M:%S %z'
        res = datetime.strptime(t1, df) - datetime.strptime(t2, df)
        return str(abs(int(res.total_seconds())))
    
  • + 0 comments
    from datetime import datetime
    
    # Complete the time_delta function below.
    def time_delta(t1, t2):
        d_format = "%a %d %b %Y %H:%M:%S %z"
    
        time_stamp1 = datetime.strptime(t1, d_format)
        time_stamp2 = datetime.strptime(t2, d_format)
    
        time_dif = time_stamp2 - time_stamp1
    
        time_delta_in_seconds = abs(time_dif.total_seconds())
    
        return str(int(time_delta_in_seconds))
    
  • + 0 comments
    import os
    from datetime import datetime as dt
    def time_delta(t1, t2):
        fmt = "%a %d %b %Y %H:%M:%S %z"
        deltaSeconds = abs((dt.strptime(t1, fmt)- dt.strptime(t2, fmt)).total_seconds())
        return str(int(deltaSeconds))
    if __name__ == '__main__':
        with open(os.environ['OUTPUT_PATH'], 'w') as fptr:
            for t_itr in range(int(input())):
                t1 = input()
                t2 = input()
                fptr.write(time_delta(t1, t2) + '\n')
    
  • + 0 comments

    !/bin/python3

    import math import os import random import re import sys from datetime import datetime

    Complete the time_delta function below.

    def time_delta(t1, t2): dt1, dt2 = [datetime.strptime(x, '%a %d %b %Y %H:%M:%S %z') for x in [t1, t2]] return str(abs(int((dt1 - dt2).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()
    
  • + 0 comments

    absolute difference (in seconds) between them.