RE: Time conversion...
- Posted by leviathan at uswest.net
Feb 26, 2001
> Hi again "LEV",
>
> 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.
Or perhaps two routines to do it, one with hours, and one without?
Or even an entire time conversion routine? (Minutes into seconds,
hours+minutes into seconds, even perhaps msecs?)
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}
>
For the program I'm working on, I only get things that are usually
below 60 minutes, and even ones above that, I don't bother with
anyway, because that'd be one big freaking MP3 file! :)
> 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.
>
Again, in my case, I don't come across decimal seconds, but again,
yeah, passing atoms instead of integers is a better idea.
> 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.
>
Which is what I was just thinking about too :)
> Good luck with it.
Luckily, I found exactly what I needed, however, I know full well that
I'll need some stuff that manipulates time like that later on, so I
should just go and wrap some time functions :) (Perhaps after I
learn how to wrap dlls)
--"LEVIATHAN"
|
Not Categorized, Please Help
|
|