From 7f10f8d28de464735bec52f51824d6931f429379 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sat, 27 Feb 2016 00:13:37 +0100 Subject: [PATCH] add STD_put_time_NOT_SUPPORTED --- include/nana/c++defines.hpp | 8 ++++++- include/nana/deploy.hpp | 18 ++++++++++++++++ source/deploy.cpp | 43 +++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/include/nana/c++defines.hpp b/include/nana/c++defines.hpp index d23e0a48..f7ac48e5 100644 --- a/include/nana/c++defines.hpp +++ b/include/nana/c++defines.hpp @@ -31,6 +31,7 @@ * - _SCL_SECURE_NO_WARNNGS, _CRT_SECURE_NO_DEPRECATE (VC) * - STD_CODECVT_NOT_SUPPORTED (VC RC, is a known issue on libstdc++, it works on libc++) * - STD_THREAD_NOT_SUPPORTED (GCC < 4.8.1) + * - STD_put_time_NOT_SUPPORTED (GCC < 5) * - STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED (MinGW with GCC < 4.8.1) * - STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED (MinGW with GCC < 4.8.1) * - STD_TO_STRING_NOT_SUPPORTED (MinGW with GCC < 4.8) @@ -133,8 +134,13 @@ #endif #endif + + #if ((__GNUC__ > 5) ) + # defie STD_put_time_NOT_SUPPORTED + #endif + #if ((__GNUC__ > 5) || ((__GNUC__ == 5) && (__GNUC_MINOR__ >= 3 ) ) ) - #undef STD_FILESYSTEM_NOT_SUPPORTED + # undef STD_FILESYSTEM_NOT_SUPPORTED #endif #if (__GNUC__ == 4) diff --git a/include/nana/deploy.hpp b/include/nana/deploy.hpp index 35659972..afb955da 100644 --- a/include/nana/deploy.hpp +++ b/include/nana/deploy.hpp @@ -92,6 +92,24 @@ namespace std } #endif +#ifdef STD_put_time_NOT_SUPPORTED +namespace std +{ + //Workaround for no implemenation of std::put_time in gcc < 5. + /* std unspecified return type */ + //template< class CharT, class RTSTR >// let fail for CharT != char / wchar_t + //RTSTR put_time(const std::tm* tmb, const CharT* fmt); + + //template< > + std::string put_time/**/(const std::tm* tmb, const char* fmt); + + //Defined in header + // std::size_t strftime(char* str, std::size_t count, const char* format, const std::tm* time); + //template<> + //std::wstring put_time(const std::tm* tmb, const wchar_t* fmt); +} +#endif // STD_put_time_NOT_SUPPORTED + namespace nana { /// Checks whether a specified text is utf8 encoding diff --git a/source/deploy.cpp b/source/deploy.cpp index 3592a3bf..91c4300d 100644 --- a/source/deploy.cpp +++ b/source/deploy.cpp @@ -436,6 +436,49 @@ namespace std } #endif +//#ifdef STD_put_time_NOT_SUPPORTED +#include +#include +namespace std +{ + //Workaround for no implemenation of std::put_time in gcc < 5. + /* std unspecified return type */ + //template< class CharT, class RTSTR >// let fail for CharT != char / wchar_t + //RTSTR put_time(const std::tm* tmb, const CharT* fmt); + + //template< > + std::string put_time/**/(const std::tm* tmb, const char* fmt) + { + unsigned sz = 200; + std::string str(sz, '\0'); + sz = std::strftime(&str[0], str.size() - 1, fmt, tmb); + str.resize(sz); + return str; + } + //Defined in header + // std::size_t strftime(char* str, std::size_t count, const char* format, const std::tm* time); + //template<> + //std::wstring put_time(const std::tm* tmb, const wchar_t* fmt) + //{ + // unsigned sz = 200; + // std::wstring str(sz, L'\0'); + // sz = std::wcsftime(&str[0], str.size() - 1, fmt, tmb); + // str.resize(sz); + // return str; + //} + // http://en.cppreference.com/w/cpp/chrono/c/wcsftime + // Defined in header + // std::size_t wcsftime(wchar_t* str, std::size_t count, const wchar_t* format, const std::tm* time); + // Converts the date and time information from a given calendar time time to a null - terminated + // wide character string str according to format string format.Up to count bytes are written. + // Parameters + // str - pointer to the first element of the wchar_t array for output + // count - maximum number of wide characters to write + // format - pointer to a null - terminated wide character string specifying the format of conversion. + + } +//#endif // STD_put_time_NOT_SUPPORTED + namespace nana { bool is_utf8(const char* str, unsigned len)