repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / mediaplayer / support / DurationToString.cpp
blobd3da3e0877885f4e7c871388d0a9e36f38dd55db
1 /*
2 * Copyright 2010, Stephan Aßmus <superstippi@gmx.de>
3 * Distributed under the terms of the MIT License.
4 */
7 #include "DurationToString.h"
9 #include <stdio.h>
12 void
13 duration_to_string(int32 seconds, char* string, size_t stringSize)
15 bool negative = seconds < 0;
16 if (negative)
17 seconds = -seconds;
19 int32 hours = seconds / 3600;
20 seconds -= hours * 3600;
21 int32 minutes = seconds / 60;
22 seconds = seconds % 60;
24 if (hours > 0) {
25 snprintf(string, stringSize, "%s%" B_PRId32 ":%02" B_PRId32 ":%02"
26 B_PRId32, negative ? "-" : "", hours, minutes, seconds);
27 } else {
28 snprintf(string, stringSize, "%s%" B_PRId32 ":%02" B_PRId32,
29 negative ? "-" : "", minutes, seconds);