Merge pull request #3107

b7e5a70b epee: detect strptime, use std::get_time as fallback (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2018-01-18 18:14:12 -05:00
commit d2ff91cb17
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD
2 changed files with 10 additions and 0 deletions

View file

@ -150,8 +150,14 @@ POP_WARNINGS
else if (boost::regex_match (from, boost::regex("\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\dZ")))
{
// Convert to unix timestamp
#ifdef HAVE_STRPTIME
struct tm tm;
if (strptime(from.c_str(), "%Y-%m-%dT%H:%M:%S", &tm))
#else
std::tm tm = {};
std::istringstream ss(from);
if (ss >> std::get_time(&tm, "%Y-%m-%dT%H:%M:%S"))
#endif
to = std::mktime(&tm);
} else
ASSERT_AND_THROW_WRONG_CONVERSION();