summaryrefslogtreecommitdiffstats
path: root/karm/karmutility.cpp
blob: 8a2de530a4e2f4a662aeb1e1f3f011ccfa9a23e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef KARM_UTILITY_H
#define KARM_UTILITY_H

#include <stdlib.h>

#include <kglobal.h>
#include <klocale.h>
#include "karmutility.h"

TQString formatTime( long minutes, bool decimal )
{
  TQString 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