Skip to content

Instantly share code, notes, and snippets.

@elliotwutingfeng
Created August 5, 2024 08:23
Show Gist options
  • Save elliotwutingfeng/8136198b8cec200345756a0cca348aad to your computer and use it in GitHub Desktop.
Save elliotwutingfeng/8136198b8cec200345756a0cca348aad to your computer and use it in GitHub Desktop.
time difference in seconds
def seconds_diff(time1: str, time2: str) -> int:
def to_seconds(time_str: str) -> int:
minutes, seconds = map(int, time_str.split(':', 1))
return minutes * 60 + seconds
return abs(to_seconds(time1) - to_seconds(time2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment