A few weeks ago I was working on a feature where I wanted to output human readable time spans, similar to what you might see in Youtube’s video player for keeping track of the time.
12:50 and so on.
I wrote a blog post that defines the spec in more detail and included both a Python and Elixir code example of how I solved the problem. There’s also a code solution from Greg Vaughn because he happened to be on Slack at the time of when I asked a question around solving this problem.
I thought maybe it would be interesting to post it here just to see how others would solve the problem. I have a feeling there’s probably 20 different ways this could be solved and the last time I posted something like this (a request for others to post their code to solve a real world problem) it had a lot of great submissions and discussions.
The spec and code examples can be found here: https://nickjanetakis.com/blog/formatting-seconds-into-hh-mm-ss-with-elixir-and-python. If you only care about the code, skim around. You’ll find the code blocks in a few seconds.
Feel free to post your code here.