Created
August 5, 2024 08:23
-
-
Save elliotwutingfeng/8136198b8cec200345756a0cca348aad to your computer and use it in GitHub Desktop.
time difference in seconds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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