diff --git a/src/Utils.cpp b/src/Utils.cpp index a5c7293..36186f0 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -148,18 +148,17 @@ int my_mkdir(const std::string& path, int perms) char* my_strptime(const char* s, const char* f, struct tm* tm) -{ - // just use normal strptime, the DIY implementation was being Weird - return strptime(s, f, tm); - - // std::istringstream input(s); - // input.imbue(std::locale(setlocale(LC_ALL, nullptr))); - // input >> std::get_time(tm, f); - // if (input.fail()) - // { - // return nullptr; - // } - // return (char*)(s + input.tellg()); +try { + std::istringstream input(s); + input.imbue(std::locale::classic()); + input >> std::get_time(tm, f); + if (input.fail()) + { + return nullptr; + } + return (char*)(s + input.tellg()); +} catch (...) { + return nullptr; } // http://stackoverflow.com/a/11366985