summaryrefslogtreecommitdiffstats
path: root/karm/karmutility.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'karm/karmutility.cpp')
-rw-r--r--karm/karmutility.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/karm/karmutility.cpp b/karm/karmutility.cpp
new file mode 100644
index 000000000..1663b178c
--- /dev/null
+++ b/karm/karmutility.cpp
@@ -0,0 +1,23 @@
+#ifndef KARM_UTILITY_H
+#define KARM_UTILITY_H
+
+#include <stdlib.h>
+
+#include <kglobal.h>
+#include <klocale.h>
+#include "karmutility.h"
+
+QString formatTime( long minutes, bool decimal )
+{
+ QString time;
+ if ( decimal ) {
+ time.sprintf("%.2f", minutes / 60.0);
+ time.replace( '.', KGlobal::locale()->decimalSymbol() );
+ }
+ else time.sprintf("%s%ld:%02ld",
+ (minutes < 0) ? KGlobal::locale()->negativeSign().utf8().data() : "",
+ labs(minutes / 60), labs(minutes % 60));
+ return time;
+}
+
+#endif // KARM_UTILITY_H