#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2023 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_SUPPORT_TEXT_QUANTITYFORMATTER_H #define NUCLEX_SUPPORT_TEXT_QUANTITYFORMATTER_H #include "Nuclex/Support/Config.h" #include // for std::string #include // for std::optional #include // for std::uint32_t, std::int32_t, std::uint64_t, std::int64_t #include // for std::chrono::seconds namespace Nuclex { namespace Support { namespace Text { // ------------------------------------------------------------------------------------------- // /// Converts quantities into human-readable strings class NUCLEX_SUPPORT_TYPE QuantityFormatter { /// Turns a byte count into a human-readable string /// Byte count for which a string will be generated /// /// Whether to output KiB, GiB and TiB, each being 1024 of the next lower unit rather /// than decimal SI units with KB, GB and TB being 1000 of the next lower unit each. /// public: NUCLEX_SUPPORT_API static std::string StringFromByteCount( std::uint64_t byteCount, bool useBinaryMagnitudes = true ); /// Turns a duration in seconds into a human-readable string /// Duration for which a string will be generated /// /// If true, the string will spell out the duration as a single number and unit /// ("5.5 minutes"), otherwise, it will indicate the exact duration as /// the number of days, hours, minutes and seconds ("1d 1:34:12") /// /// /// This is a simple helper with no localization. While the strings generated /// should be universally understood, they will use English terms for the units. /// public: NUCLEX_SUPPORT_API static std::string StringFromDuration( std::chrono::seconds duration, bool useSimpleFormat = true ); // Duration // Elapsed time since UTC timestamp // Reamining time }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Support::Text #endif // NUCLEX_SUPPORT_TEXT_QUANTITYFORMATTER_H