diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-03-15 16:39:50 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-03-15 16:40:02 +0100 |
commit | cb0c42e7dad3d92276cfa62c66e6f298ea33c78a (patch) | |
tree | ded4afb293915c35da977de52fad5eae862dcd63 | |
parent | acfe60677c9bb4e75cf2e139b2dee4b642ee6a0c (diff) | |
parent | a1465ac8e678ecfcadbac20e0aba4dd406271467 (diff) |
Merge pull request #3876
a1465ac qt: Show weeks as well as years behind for long timespans (Wladimir J. van der Laan)
-rw-r--r-- | src/qt/bitcoingui.cpp | 20 | ||||
-rw-r--r-- | src/qt/locale/bitcoin_en.ts | 13 |
2 files changed, 28 insertions, 5 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 0ca16edb8c..da7762282a 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -673,17 +673,27 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks) { // Represent time from last generated block in human readable text QString timeBehindText; - if(secs < 48*60*60) + const int HOUR_IN_SECONDS = 60*60; + const int DAY_IN_SECONDS = 24*60*60; + const int WEEK_IN_SECONDS = 7*24*60*60; + const int YEAR_IN_SECONDS = 31556952; // Average length of year in Gregorian calendar + if(secs < 2*DAY_IN_SECONDS) { - timeBehindText = tr("%n hour(s)","",secs/(60*60)); + timeBehindText = tr("%n hour(s)","",secs/HOUR_IN_SECONDS); } - else if(secs < 14*24*60*60) + else if(secs < 2*WEEK_IN_SECONDS) { - timeBehindText = tr("%n day(s)","",secs/(24*60*60)); + timeBehindText = tr("%n day(s)","",secs/DAY_IN_SECONDS); + } + else if(secs < YEAR_IN_SECONDS) + { + timeBehindText = tr("%n week(s)","",secs/WEEK_IN_SECONDS); } else { - timeBehindText = tr("%n week(s)","",secs/(7*24*60*60)); + int years = secs / YEAR_IN_SECONDS; + int remainder = secs % YEAR_IN_SECONDS; + timeBehindText = tr("%1 and %2").arg(tr("%n year(s)", "", years)).arg(tr("%n week(s)","", remainder/WEEK_IN_SECONDS)); } progressBarLabel->setVisible(true); diff --git a/src/qt/locale/bitcoin_en.ts b/src/qt/locale/bitcoin_en.ts index 628847e030..ebcfde35c4 100644 --- a/src/qt/locale/bitcoin_en.ts +++ b/src/qt/locale/bitcoin_en.ts @@ -637,6 +637,19 @@ This product includes software developed by the OpenSSL Project for use in the O </translation> </message> <message> + <location line="+0"/> + <source>%1 and %2</source> + <translation type="unfinished"></translation> + </message> + <message numerus="yes"> + <location line="+0"/> + <source>%n year(s)</source> + <translation type="unfinished"> + <numerusform>%n year</numerusform> + <numerusform>%n years</numerusform> + </translation> + </message> + <message> <location line="+4"/> <source>%1 behind</source> <translation>%1 behind</translation> |