I have been trying to make a function that lists the time between dates using the correct words, in particular I want it to account for plural. I know I can do this by running all the numbers through and if statement, but I really was hoping to find a more efficient way to accomplish my goal.
IE: I want 221 days, 1:17:06.996068
from datetime
to be returned as 221 days, 1 hour, 17 minutes, and 6.99 seconds.
With it being important it says day/hour/minute/second or days/hours/minutes/seconds when appropriate.
Example snippet of my code to work with:
from datetime import datetime as dt
now = dt.now(tz=None) # Current local computer time
test = dt(2018,3,25,23,0,0) # March 25th, 2018 23h 0m 0s
countdown = test - now
print(countdown) # 2 days, 1:45:00.685739
# Desired outcome: 2 days, 1 hour, 45 minutes, 0.68 seconds.
Is there any kind of function that labels between singular or plural time that efficiently?