aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <[email protected]>2014-05-23 15:41:14 +0200
committerWladimir J. van der Laan <[email protected]>2014-05-23 15:52:45 +0200
commit97b53b581b637f4c8089133e7d4bcd6e2a8761c8 (patch)
treeb5b628c1843b76214d97ceb801e6a971283566db /src/util.cpp
parentMerge pull request #4212 (diff)
parentReplace non-threadsafe gmtime and setlocale (diff)
downloaddiscoin-97b53b581b637f4c8089133e7d4bcd6e2a8761c8.tar.xz
discoin-97b53b581b637f4c8089133e7d4bcd6e2a8761c8.zip
Merge pull request #4152
3e8ac6a Replace non-threadsafe gmtime and setlocale (Wladimir J. van der Laan) a60838d Replace non-threadsafe strerror (Wladimir J. van der Laan)
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util.cpp b/src/util.cpp
index aa3adf89e..f7ceb3e95 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -14,6 +14,8 @@
#include <stdarg.h>
+#include <boost/date_time/posix_time/posix_time.hpp>
+
#ifndef WIN32
// for posix_fallocate
#ifdef __linux_
@@ -1400,3 +1402,13 @@ void SetupEnvironment()
}
#endif
}
+
+std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime)
+{
+ // std::locale takes ownership of the pointer
+ std::locale loc(std::locale::classic(), new boost::posix_time::time_facet(pszFormat));
+ std::stringstream ss;
+ ss.imbue(loc);
+ ss << boost::posix_time::from_time_t(nTime);
+ return ss.str();
+}