MCPcopy Create free account
hub / github.com/geekcomputers/Python / calculate_time_delta

Function calculate_time_delta

time_delta.py:53–70  ·  view source on GitHub ↗

Calculate the absolute time difference between two timestamps in seconds. Args: t1: First timestamp string t2: Second timestamp string Returns: Absolute time difference in seconds as an integer

(t1: str, t2: str)

Source from the content-addressed store, hash-verified

51
52
53def calculate_time_delta(t1: str, t2: str) -> int:
54 """
55 Calculate the absolute time difference between two timestamps in seconds.
56
57 Args:
58 t1: First timestamp string
59 t2: Second timestamp string
60
61 Returns:
62 Absolute time difference in seconds as an integer
63 """
64 # Parse both timestamps
65 dt1 = parse_timestamp(t1)
66 dt2 = parse_timestamp(t2)
67
68 # Calculate absolute difference and convert to seconds
69 time_difference = abs(dt1 - dt2)
70 return int(time_difference.total_seconds())
71
72
73def read_test_cases() -> Tuple[int, List[Tuple[str, str]]]:

Callers 1

mainFunction · 0.85

Calls 1

parse_timestampFunction · 0.85

Tested by

no test coverage detected