fix: Fix the ledger_index timezone issue (#1522)

Fix unittest failures
This commit is contained in:
cyan317
2024-07-09 13:14:22 +01:00
committed by GitHub
parent d536433d64
commit 094ed8f299
8 changed files with 167 additions and 14 deletions

View File

@@ -22,6 +22,7 @@
#include "rpc/Errors.hpp"
#include "rpc/RPCHelpers.hpp"
#include "rpc/common/Types.hpp"
#include "util/TimeUtils.hpp"
#include <boost/json/object.hpp>
#include <boost/json/value.hpp>
@@ -65,10 +66,8 @@ TimeFormatValidator::verify(boost::json::value const& value, std::string_view ke
if (not value.as_object().at(key).is_string())
return Error{Status{RippledError::rpcINVALID_PARAMS}};
std::tm time = {};
std::stringstream stream(value_to<std::string>(value.as_object().at(key)));
stream >> std::get_time(&time, format_.c_str());
if (stream.fail())
auto const ret = util::SystemTpFromUTCStr(value_to<std::string>(value.as_object().at(key)), format_);
if (!ret)
return Error{Status{RippledError::rpcINVALID_PARAMS}};
return {};