added years to userFriendlyDuration

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1687 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2009-09-25 16:19:58 +00:00
parent 09cfa7e070
commit 12450ececa

View File

@ -309,7 +309,7 @@ class misc : public QObject{
} }
int minutes = seconds / 60; int minutes = seconds / 60;
if(minutes < 60) { if(minutes < 60) {
return tr("%1m","e.g: 10minutes").arg(QString::QString::fromUtf8(misc::toString(minutes).c_str())); return tr("%1 minutes","e.g: 10minutes").arg(QString::QString::fromUtf8(misc::toString(minutes).c_str()));
} }
int hours = minutes / 60; int hours = minutes / 60;
minutes = minutes - hours*60; minutes = minutes - hours*60;
@ -321,6 +321,11 @@ class misc : public QObject{
if(days < 365) { if(days < 365) {
return tr("%1d %2h %3m", "e.g: 2days 10hours 2minutes").arg(QString::fromUtf8(misc::toString(days).c_str())).arg(QString::fromUtf8(misc::toString(hours).c_str())).arg(QString::fromUtf8(misc::toString(minutes).c_str())); return tr("%1d %2h %3m", "e.g: 2days 10hours 2minutes").arg(QString::fromUtf8(misc::toString(days).c_str())).arg(QString::fromUtf8(misc::toString(hours).c_str())).arg(QString::fromUtf8(misc::toString(minutes).c_str()));
} }
int years = days / 365;
days = days - years * 365;
if(years > 1) {
return tr("%1y %1d %2h %3m", "e.g: 2 years 2days 10hours 2minutes").arg(QString::fromUtf8(misc::toString(years).c_str())).arg(QString::fromUtf8(misc::toString(days).c_str())).arg(QString::fromUtf8(misc::toString(hours).c_str())).arg(QString::fromUtf8(misc::toString(minutes).c_str()));
}
return tr("Unknown"); return tr("Unknown");
} }
}; };