I suspect it could be made much cleaner with datetime.timedelta objects rather than throwing around what I assume is a float of seconds since the epoch (as from time.time()).

I'm not about to go trying to write a nicer version (certainly there's not really a problem if that one works), but django.util.timesince may offer a slightly cleaner way to do it, the salient part being at around line 42.
Forgot that everything I'll be dealing with here is in seconds, so I made it so it always inputs integers, so I could simplify it a bit.

Was thinking about making it so it uses _ for checking if the values equal one or are greater than 1, then uses that same value for placing into the string, but I'm not entirely sure that will be any smaller or simpler.
I would expect it to be smaller; whether it would be simpler is open for interpretation.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 3 of 3
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement