mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-27 05:13:25 +01:00
Merge pull request #3107
b7e5a70b
epee: detect strptime, use std::get_time as fallback (moneromooo-monero)
This commit is contained in:
commit
d2ff91cb17
@ -868,5 +868,9 @@ option(INSTALL_VENDORED_LIBUNBOUND "Install libunbound binary built from source
|
|||||||
|
|
||||||
CHECK_C_COMPILER_FLAG(-std=c11 HAVE_C11)
|
CHECK_C_COMPILER_FLAG(-std=c11 HAVE_C11)
|
||||||
|
|
||||||
|
include(CheckLibraryExists)
|
||||||
|
include(CheckFunctionExists)
|
||||||
|
|
||||||
check_library_exists(c memset_s "string.h" HAVE_MEMSET_S)
|
check_library_exists(c memset_s "string.h" HAVE_MEMSET_S)
|
||||||
check_library_exists(c explicit_bzero "strings.h" HAVE_EXPLICIT_BZERO)
|
check_library_exists(c explicit_bzero "strings.h" HAVE_EXPLICIT_BZERO)
|
||||||
|
check_function_exists(strptime HAVE_STRPTIME)
|
||||||
|
@ -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")))
|
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
|
// Convert to unix timestamp
|
||||||
|
#ifdef HAVE_STRPTIME
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
if (strptime(from.c_str(), "%Y-%m-%dT%H:%M:%S", &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);
|
to = std::mktime(&tm);
|
||||||
} else
|
} else
|
||||||
ASSERT_AND_THROW_WRONG_CONVERSION();
|
ASSERT_AND_THROW_WRONG_CONVERSION();
|
||||||
|
Loading…
Reference in New Issue
Block a user