[vorbis-dev] ogg123 -k 1:59 patch.ogg # minutes and seconds
Segher Boessenkool
segher at koffie.nl
Sun Mar 2 07:44:46 PST 2003
Hans Schou wrote:
> I guess my patch is a little buggy and would like to improve it upon
> request (guidelines are welcome). Anyway, here it is:
In pseudo-code, I'd do:
time := get number
while next character is ':'
skip that ':'
time := 60*time + get number
That way, things like 2:14:01 parse, too. You can also accept
fractional seconds with this, like in 5:49.216 for example,
by having "get number" get floating point numbers, not integer.
(You'll have to temporarily set the locale to "C" for this
to work perfectly; otherwise, the locale-specific decimal
point is used instead of '.', and that is not appropriate).
Ah well, I'll write it in C for you [completely untested!]
(leaving out the locale stuff).
double strtotime(const char *s)
{
double time;
time = strtod(s, &s);
while (*s == ':')
time = 60 * time + strtod(s + 1, &s);
return time;
}
<p>Good luck,
Segher
<p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the Vorbis-dev
mailing list