diff options
author | Thomas Keil <tkeil (at) datacrystal (dot) de> | 2007-05-01 13:44:09 +0000 |
---|---|---|
committer | Thomas Keil <tkeil (at) datacrystal (dot) de> | 2007-05-01 13:44:09 +0000 |
commit | a7353164a339d29e3534b5534171175ee679a360 (patch) | |
tree | de93dfcee3cc56468c4d7834a4b26d4529c5b6eb | |
parent | b3a350b379c46e4c8b56415fadf07fb7c9749621 (diff) | |
download | vdr-plugin-live-a7353164a339d29e3534b5534171175ee679a360.tar.gz vdr-plugin-live-a7353164a339d29e3534b5534171175ee679a360.tar.bz2 |
Added function ZeroPad to pad numbers with leading zeroes, e.g. 5 -> 05
-rw-r--r-- | tools.cpp | 10 | ||||
-rw-r--r-- | tools.h | 1 |
2 files changed, 11 insertions, 0 deletions
@@ -1,4 +1,5 @@ #include <stdexcept> +#include <iomanip> #include <tnt/ecpp.h> #include <tnt/htmlescostream.h> #include <tnt/httprequest.h> @@ -8,6 +9,7 @@ #include "setup.h" #include "tools.h" + using namespace std; using namespace tnt; @@ -121,4 +123,12 @@ string StringTrim(string const& str) return res; } +string ZeroPad(int number) +{ + ostringstream os; + os << setw(2) << setfill('0') << number; + return os.str(); +} + + } // namespace vdrlive @@ -30,6 +30,7 @@ std::string StringWordTruncate(const std::string& input, size_t maxLen, bool& tr std::string StringEscapeAndBreak( std::string const& input ); std::string StringFormatBreak(std::string const& input); std::string StringTrim(const std::string& str); +std::string ZeroPad(int number); struct bad_lexical_cast: std::runtime_error { |