Last active
June 12, 2020 04:05
-
-
Save walison17/2706af96ec66b55cca9119469db68055 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from datetime import datetime | |
def make_datetime(date, time): | |
return datetime( | |
year=date.year, | |
month=date.month, | |
day=date.day, | |
hour=time.hour, | |
minute=time.minute, | |
second=time.second | |
) | |
def parse_duration(duration): | |
seconds = duration.total_seconds() | |
hours = total_seconds // 3600 | |
seconds %= 3600 | |
minutes = seconds // 60 | |
seconds %= 60 | |
return hours, minutes, seconds | |
start = make_datetime(start_date, start_time) | |
end = make_datetime(end_date, end_time) | |
duration = end - start | |
hours, minutes, seconds = parse_duration(duration) | |
print(f'{hours}h, {minutes}min and {seconds}s') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment