mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
Make format_time properly format negative times because sometimes they are shown if track length estimates are off from seeking. Example: -0:15 instead of 0:-15. -1000ms < t < 0 is shown as -0:00.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29343 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
9d2c7b8b67
commit
03862292a2
1 changed files with 10 additions and 6 deletions
16
apps/misc.c
16
apps/misc.c
|
@ -894,16 +894,20 @@ char* skip_whitespace(char* const str)
|
|||
*/
|
||||
void format_time(char* buf, int buf_size, long t)
|
||||
{
|
||||
if ( t < 3600000 )
|
||||
int const time = ABS(t / 1000);
|
||||
int const hours = time / 3600;
|
||||
int const minutes = time / 60 - hours * 60;
|
||||
int const seconds = time % 60;
|
||||
const char * const sign = &"-"[t < 0 ? 0 : 1];
|
||||
|
||||
if ( hours == 0 )
|
||||
{
|
||||
snprintf(buf, buf_size, "%d:%02d",
|
||||
(int) (t / 60000), (int) (t % 60000 / 1000));
|
||||
snprintf(buf, buf_size, "%s%d:%02d", sign, minutes, seconds);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(buf, buf_size, "%d:%02d:%02d",
|
||||
(int) (t / 3600000), (int) (t % 3600000 / 60000),
|
||||
(int) (t % 60000 / 1000));
|
||||
snprintf(buf, buf_size, "%s%d:%02d:%02d", sign, hours, minutes,
|
||||
seconds);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue