Skip to content

Instantly share code, notes, and snippets.

@vskrachkov
Created November 30, 2019 23:13
Show Gist options
  • Save vskrachkov/7e1b5751fbe6ed572568637b8409b53f to your computer and use it in GitHub Desktop.
Save vskrachkov/7e1b5751fbe6ed572568637b8409b53f to your computer and use it in GitHub Desktop.
def to_minutes(wd, h, m):
return wd * 24 * 60 + h * 60 + m
def from_minutes(minutes):
wd = minutes // (24 * 60)
rest = minutes - (wd * 24 * 60)
return wd, rest // 60, rest % 60
if __name__ == '__main__':
print(f'from_minutes(to_minutes(2, 23, 45)) -> {from_minutes(to_minutes(2, 23, 45))}')
print(f'from_minutes(to_minutes(2, 21, 45)) -> {from_minutes(to_minutes(2, 21, 45))}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment