Skip to content

Instantly share code, notes, and snippets.

@MattHealy
Created May 16, 2019 03:27
Show Gist options
  • Save MattHealy/08d22918ee430555c0a990c0c80797cb to your computer and use it in GitHub Desktop.
Save MattHealy/08d22918ee430555c0a990c0c80797cb to your computer and use it in GitHub Desktop.
Convert minutes in to days, hours and minutes
def convert(minutes):
if isinstance(minutes, int):
return str(minutes/24/60) + " day, " + \
str(minutes/60 % 24) + " hours, " + \
str(minutes % 60) + " minutes"
else:
return "0 days, 0 hours, 0 minutes"
if __name__ == "__main__":
values = [180, 181, 31, 1450, 1440, 1800, 1840, -100, None, 0]
for val in values:
print(str(val) + " minutes is " + convert(val))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment