MCPcopy Create free account
hub / github.com/ElementsProject/elements / formatNiceTimeOffset

Function formatNiceTimeOffset

src/qt/guiutil.cpp:833–868  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

831}
832
833QString formatNiceTimeOffset(qint64 secs)
834{
835 // Represent time from last generated block in human readable text
836 QString timeBehindText;
837 const int HOUR_IN_SECONDS = 60*60;
838 const int DAY_IN_SECONDS = 24*60*60;
839 const int WEEK_IN_SECONDS = 7*24*60*60;
840 const int YEAR_IN_SECONDS = 31556952; // Average length of year in Gregorian calendar
841 if(secs < 60)
842 {
843 timeBehindText = QObject::tr("%n second(s)","",secs);
844 }
845 else if(secs < 2*HOUR_IN_SECONDS)
846 {
847 timeBehindText = QObject::tr("%n minute(s)","",secs/60);
848 }
849 else if(secs < 2*DAY_IN_SECONDS)
850 {
851 timeBehindText = QObject::tr("%n hour(s)","",secs/HOUR_IN_SECONDS);
852 }
853 else if(secs < 2*WEEK_IN_SECONDS)
854 {
855 timeBehindText = QObject::tr("%n day(s)","",secs/DAY_IN_SECONDS);
856 }
857 else if(secs < YEAR_IN_SECONDS)
858 {
859 timeBehindText = QObject::tr("%n week(s)","",secs/WEEK_IN_SECONDS);
860 }
861 else
862 {
863 qint64 years = secs / YEAR_IN_SECONDS;
864 qint64 remainder = secs % YEAR_IN_SECONDS;
865 timeBehindText = QObject::tr("%1 and %2").arg(QObject::tr("%n year(s)", "", years)).arg(QObject::tr("%n week(s)","", remainder/WEEK_IN_SECONDS));
866 }
867 return timeBehindText;
868}
869
870QString formatBytes(uint64_t bytes)
871{

Callers 3

setNumBlocksMethod · 0.85
setModelMethod · 0.85
tipUpdateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected