fix time conversion
This commit is contained in:
parent
0089866142
commit
af8e2cddcb
@ -69,12 +69,12 @@ auto s3_provider::convert_api_date(std::string_view date) -> std::uint64_t {
|
|||||||
struct tm tm1 {};
|
struct tm tm1 {};
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
utils::time::strptime(date_time.c_str(), "%Y-%m-%dT%T", &tm1);
|
utils::time::strptime(date_time.c_str(), "%Y-%m-%dT%T", &tm1);
|
||||||
#else
|
return utils::time::windows_time_t_to_unix_time(mktime(&tm1)) + nanos;
|
||||||
|
#else // !defined(_WIN32)
|
||||||
strptime(date_time.c_str(), "%Y-%m-%dT%T", &tm1);
|
strptime(date_time.c_str(), "%Y-%m-%dT%T", &tm1);
|
||||||
#endif
|
|
||||||
|
|
||||||
return nanos + (static_cast<std::uint64_t>(mktime(&tm1)) *
|
return nanos + (static_cast<std::uint64_t>(mktime(&tm1)) *
|
||||||
utils::time::NANOS_PER_SECOND);
|
utils::time::NANOS_PER_SECOND);
|
||||||
|
#endif // defined(_WIN32)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::create_directory_impl(const std::string &api_path,
|
auto s3_provider::create_directory_impl(const std::string &api_path,
|
||||||
|
@ -28,7 +28,8 @@ namespace repertory {
|
|||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
TEST(utils, convert_api_date) {
|
TEST(utils, convert_api_date) {
|
||||||
LARGE_INTEGER li{};
|
LARGE_INTEGER li{};
|
||||||
li.QuadPart = s3_provider::convert_api_date("2009-10-12T17:50:30.111Z");
|
li.QuadPart = utils::time::unix_time_to_windows_time(
|
||||||
|
s3_provider::convert_api_date("2009-10-12T17:50:30.111Z"));
|
||||||
|
|
||||||
SYSTEMTIME st{};
|
SYSTEMTIME st{};
|
||||||
FileTimeToSystemTime(reinterpret_cast<FILETIME *>(&li), &st);
|
FileTimeToSystemTime(reinterpret_cast<FILETIME *>(&li), &st);
|
||||||
@ -42,7 +43,7 @@ TEST(utils, convert_api_date) {
|
|||||||
|
|
||||||
EXPECT_EQ(17, lt.wHour);
|
EXPECT_EQ(17, lt.wHour);
|
||||||
EXPECT_EQ(50, lt.wMinute);
|
EXPECT_EQ(50, lt.wMinute);
|
||||||
EXPECT_EQ(20, lt.wSecond);
|
EXPECT_EQ(30, lt.wSecond);
|
||||||
EXPECT_EQ(111, lt.wMilliseconds);
|
EXPECT_EQ(111, lt.wMilliseconds);
|
||||||
}
|
}
|
||||||
#endif // defined(_WIN32)
|
#endif // defined(_WIN32)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user