diff options
| author | luigi1111 <luigi1111w@gmail.com> | 2019-08-14 15:31:52 -0500 |
|---|---|---|
| committer | luigi1111 <luigi1111w@gmail.com> | 2019-08-14 15:31:52 -0500 |
| commit | 564bb1da3a760834e306906a78301e3be93d9836 (patch) | |
| tree | 801f83e7f9ace634c47b403eddac2a2b6762ff87 /src/common/util.cpp | |
| parent | 1ed2c4043679a2b1ad3713cf961ea12091e72cc2 (diff) | |
| parent | 880ebfdeeaceab5e1ca40b748516987e9c6cecb7 (diff) | |
| download | monzero-core-564bb1da3a760834e306906a78301e3be93d9836.tar.gz monzero-core-564bb1da3a760834e306906a78301e3be93d9836.tar.xz monzero-core-564bb1da3a760834e306906a78301e3be93d9836.zip | |
Merge pull request #5525
0605406 daemon: sort alt chains by height (moneromooo-monero)
4228ee0 daemon: add optional arguments to alt_chain_info (moneromooo-monero)
880ebfd daemon: add more chain specific info in alt_chain_info (moneromooo-monero)
Diffstat (limited to 'src/common/util.cpp')
| -rw-r--r-- | src/common/util.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/common/util.cpp b/src/common/util.cpp index db5aa3052..0fa9e8dc1 100644 --- a/src/common/util.cpp +++ b/src/common/util.cpp @@ -1068,6 +1068,23 @@ std::string get_nix_version_display_string() return std::string(buffer); } + std::string get_human_readable_timespan(uint64_t seconds) + { + if (seconds < 60) + return std::to_string(seconds) + " seconds"; + if (seconds < 3600) + return std::to_string((uint64_t)(seconds / 60)) + " minutes"; + if (seconds < 3600 * 24) + return std::to_string((uint64_t)(seconds / 3600)) + " hours"; + if (seconds < 3600 * 24 * 30.5) + return std::to_string((uint64_t)(seconds / (3600 * 24))) + " days"; + if (seconds < 3600 * 24 * 365.25) + return std::to_string((uint64_t)(seconds / (3600 * 24 * 30.5))) + " months"; + if (seconds < 3600 * 24 * 365.25 * 100) + return std::to_string((uint64_t)(seconds / (3600 * 24 * 30.5 * 365.25))) + " years"; + return "a long time"; + } + std::string get_human_readable_bytes(uint64_t bytes) { // Use 1024 for "kilo", 1024*1024 for "mega" and so on instead of the more modern and standard-conforming |
