Sort by

recency

|

383 Discussions

|

  • + 0 comments
    from datetime import datetime
    
    for _ in range( int(input()) ):
        first_date = datetime.strptime(input(), "%a %d %b %Y %H:%M:%S %z")
        last_date = datetime.strptime(input(), "%a %d %b %Y %H:%M:%S %z")
        print(abs(int((first_date - last_date).total_seconds())))
    
  • + 0 comments

    def time_delta(t1, t2): struct_times = [datetime.datetime.strptime(_, "%a %d %b %Y %H:%M:%S %z") for _ in [t1, t2]]

    return "%d" % (abs(struct_times[0].timestamp() - struct_times[1].timestamp()))
    
  • + 0 comments

    Dealing with time zone differences can be confusing—just like scheduling with Movers and Packers Sharjah when you're shifting across cities!

  • + 0 comments
    1. from datetime import datetime
    2. def time_delta(t1, t2):
    3. dt_stamp = "%a %d %b %Y %H:%M:%S %z"
    4. game = datetime.strptime(t1,dt_stamp)- datetime.strptime(t2,dt_stamp)
    5. exact_sec = abs(int((game).total_seconds()))
    6. print(exact_sec)
  • + 0 comments
    #!/bin/python3
    
    import os
    from datetime import datetime
    
    # Complete the time_delta function below.
    def time_delta(t1, t2):
        # Define the date format
        date_format = "%a %d %b %Y %H:%M:%S %z"
        
        # Parse the input strings into datetime objects
        dt1 = datetime.strptime(t1, date_format)
        dt2 = datetime.strptime(t2, date_format)
        
        # Calculate the absolute difference in seconds
        delta = abs((dt1 - dt2).total_seconds())
        
        # Return the result as a string
        return str(int(delta))
    
    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()