This commit is contained in:
parent
3dc16db278
commit
cbebcfae82
@ -78,12 +78,11 @@ auto s3_provider::convert_api_date(std::string_view date) -> std::uint64_t {
|
|||||||
return nanos + utils::time::windows_time_t_to_unix_time(mktime(&tm1));
|
return nanos + utils::time::windows_time_t_to_unix_time(mktime(&tm1));
|
||||||
#else // !defined(_WIN32)
|
#else // !defined(_WIN32)
|
||||||
strptime(date_time.c_str(), "%Y-%m-%dT%T", &tm1);
|
strptime(date_time.c_str(), "%Y-%m-%dT%T", &tm1);
|
||||||
|
|
||||||
auto utc_time = timegm(&tm1);
|
auto utc_time = timegm(&tm1);
|
||||||
auto *utc_tm = localtime(&utc_time);
|
return nanos +
|
||||||
if (utc_tm != nullptr) {
|
(static_cast<std::uint64_t>(mktime(localtime_r(&utc_time, &tm1))) *
|
||||||
}
|
utils::time::NANOS_PER_SECOND);
|
||||||
return nanos + (static_cast<std::uint64_t>(mktime(&tm1)) *
|
|
||||||
utils::time::NANOS_PER_SECOND);
|
|
||||||
#endif // defined(_WIN32)
|
#endif // defined(_WIN32)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "providers/s3/s3_provider.hpp"
|
#include "providers/s3/s3_provider.hpp"
|
||||||
#include "utils/file.hpp"
|
#include "utils/file.hpp"
|
||||||
|
#include <utils/time.hpp>
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
TEST(utils, convert_api_date) {
|
TEST(utils, convert_api_date) {
|
||||||
@ -42,10 +43,18 @@ TEST(utils, convert_api_date) {
|
|||||||
EXPECT_EQ(30, st.wSecond);
|
EXPECT_EQ(30, st.wSecond);
|
||||||
EXPECT_EQ(111, st.wMilliseconds);
|
EXPECT_EQ(111, st.wMilliseconds);
|
||||||
#else // !defined(_WIN32)
|
#else // !defined(_WIN32)
|
||||||
auto unix_time = s3_provider::convert_api_date("2009-10-12T17:50:30.111Z");
|
auto unix_time = s3_provider::convert_api_date("2009-10-12T17:50:30.111Z") /
|
||||||
auto *tm_data = gmtime(&unix_time);
|
utils::time::NANOS_PER_SECOND;
|
||||||
|
auto *tm_data = gmtime(reinterpret_cast<time_t *>(&unix_time));
|
||||||
EXPECT_TRUE(tm_data != nullptr);
|
EXPECT_TRUE(tm_data != nullptr);
|
||||||
if (tm_data != nullptr) {
|
if (tm_data != nullptr) {
|
||||||
|
EXPECT_EQ(2009, tm_data->tm_year + 1900);
|
||||||
|
EXPECT_EQ(10, tm_data->tm_mon + 1);
|
||||||
|
EXPECT_EQ(12, tm_data->tm_mday);
|
||||||
|
|
||||||
|
EXPECT_EQ(17, tm_data->tm_hour);
|
||||||
|
EXPECT_EQ(50, tm_data->tm_min);
|
||||||
|
EXPECT_EQ(30, tm_data->tm_sec);
|
||||||
}
|
}
|
||||||
#endif // defined(_WIN32)
|
#endif // defined(_WIN32)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user