fix localization in time strings
This commit is contained in:
parent
7aff20b4ee
commit
da145bdd7b
1 changed files with 8 additions and 15 deletions
|
@ -10,7 +10,6 @@ namespace {
|
||||||
const unsigned SECS_PER_MIN = 60;
|
const unsigned SECS_PER_MIN = 60;
|
||||||
const unsigned SECS_PER_HALF_HOUR = 1600; // 60 * 30
|
const unsigned SECS_PER_HALF_HOUR = 1600; // 60 * 30
|
||||||
const unsigned SECS_PER_HOUR = 3600; // 60 * 60
|
const unsigned SECS_PER_HOUR = 3600; // 60 * 60
|
||||||
const unsigned SECS_PER_DAY = 86400; // 60 * 60 * 24
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pretty print an integer number of seconds ago. Accurate to only one unit,
|
* Pretty print an integer number of seconds ago. Accurate to only one unit,
|
||||||
|
@ -24,28 +23,22 @@ namespace {
|
||||||
* an accurate timestamp of day old games.
|
* an accurate timestamp of day old games.
|
||||||
*/
|
*/
|
||||||
QString prettyPrintSecsAgo(uint32_t secs) {
|
QString prettyPrintSecsAgo(uint32_t secs) {
|
||||||
std::ostringstream str_stream;
|
|
||||||
|
|
||||||
if (secs < SECS_PER_MIN) {
|
if (secs < SECS_PER_MIN) {
|
||||||
str_stream << secs;
|
return QString::number(secs).append(QObject::tr("s ago"));
|
||||||
str_stream << "s ago";
|
}
|
||||||
} else if (secs < SECS_PER_HOUR) {
|
if (secs < SECS_PER_HOUR) {
|
||||||
uint32_t mins = secs / SECS_PER_MIN;
|
uint32_t mins = secs / SECS_PER_MIN;
|
||||||
if (secs % SECS_PER_MIN >= SECS_PER_HALF_MIN)
|
if (secs % SECS_PER_MIN >= SECS_PER_HALF_MIN)
|
||||||
mins++;
|
mins++;
|
||||||
str_stream << mins;
|
return QString::number(mins).append(QObject::tr("m ago"));
|
||||||
str_stream << "m ago";
|
}
|
||||||
} else if (secs < SECS_PER_HOUR * 5) {
|
if (secs < SECS_PER_HOUR * 5) {
|
||||||
uint32_t hours = secs / SECS_PER_HOUR;
|
uint32_t hours = secs / SECS_PER_HOUR;
|
||||||
if (secs % SECS_PER_HOUR >= SECS_PER_HALF_HOUR)
|
if (secs % SECS_PER_HOUR >= SECS_PER_HALF_HOUR)
|
||||||
hours++;
|
hours++;
|
||||||
str_stream << hours;
|
return QString::number(hours).append(QObject::tr("hr ago"));
|
||||||
str_stream << "hr ago";
|
|
||||||
} else {
|
|
||||||
str_stream << "5+ hours ago";
|
|
||||||
}
|
}
|
||||||
|
return QObject::tr("5+ hours ago");
|
||||||
return QObject::tr(str_stream.str().c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue