RE: Time conversion...
- Posted by Al Getz <Xaxo at aol.com> Feb 26, 2001
- 406 views
Hi again "LEV", leviathan at uswest.net wrote: > Whoa, wow, okay... I'm very impressed :) > > Clearly the tightest fuction here was Jiris secs2mins function, blew > my > mind away when I saw that all the fuctions that did it came out to do > all > the same thing :) And look what it took me! Too many lines of code! > Whee! > > Anyway, thanx everyone for contributing, can we stick this into the > EuSLP? (Eu Standard Libraries Project?) > > Thanx all, > > --"LEVIATHAN" > > In my opinion, if your going to wrap a time function like that you should go all the way and include hours as well, in case someone inputs a high number for the seconds parameter. This way you get the output 05:02:03 {hours:mins:secs} for an input of 5*60*60 + 2*60 + 3 instead of an output of 302:03 {mins:secs} Secondly, using an integer as input parameter means the user has to round the seconds input themselves. Rounding within the function (passing atom) means you can get 119.99 seconds to come out as 00:02:00 {hours:mins:seconds} without bothering the user with this detail. The shortest function isnt always the best, as the most versatile functions are almost always longer then any others and are more suited to inclusion into a library. Consider a second parameter, that specifies whether or not to output hours:mins:secs or just mins:secs or even days:hours:mins:secs or even several other formats to cover many possible applications. Good luck with it. --Al