Use ENCODINGTIME to set the added time, if present, otherwise use the last modified time of the file (only during the first import), fixes #595
This commit is contained in:
@@ -476,6 +476,12 @@ namespace lms::core::stringUtils
|
||||
return date.toString("yyyy-MM-dd").toUTF8();
|
||||
}
|
||||
|
||||
Wt::WDateTime fromISO8601String(std::string_view dateTime)
|
||||
{
|
||||
// assume UTC
|
||||
return Wt::WDateTime::fromString(Wt::WString{ std::string{ dateTime } }, "yyyy-MM-ddThh:mm:ss.zzz");
|
||||
}
|
||||
|
||||
std::string formatTimestamp(std::chrono::milliseconds timestamp)
|
||||
{
|
||||
using namespace std::chrono;
|
||||
|
||||
@@ -116,6 +116,8 @@ namespace lms::core::stringUtils
|
||||
[[nodiscard]] std::string toISO8601String(const Wt::WDateTime& dateTime);
|
||||
[[nodiscard]] std::string toISO8601String(const Wt::WDate& date);
|
||||
|
||||
[[nodiscard]] Wt::WDateTime fromISO8601String(std::string_view dateTime);
|
||||
|
||||
// to "[minutes:seconds.milliseconds]"
|
||||
std::string formatTimestamp(std::chrono::milliseconds timestamp);
|
||||
} // namespace lms::core::stringUtils
|
||||
@@ -299,18 +299,25 @@ namespace lms::core::stringUtils::tests
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Stringutils, date)
|
||||
TEST(Stringutils, DateToString)
|
||||
{
|
||||
const Wt::WDate date{ 2020, 01, 03 };
|
||||
EXPECT_EQ(toISO8601String(date), "2020-01-03");
|
||||
}
|
||||
|
||||
TEST(Stringutils, dateTime)
|
||||
TEST(Stringutils, DateTimeToString)
|
||||
{
|
||||
const Wt::WDateTime dateTime{ Wt::WDate{ 2020, 01, 03 }, Wt::WTime{ 9, 8, 11, 75 } };
|
||||
EXPECT_EQ(toISO8601String(dateTime), "2020-01-03T09:08:11.075");
|
||||
}
|
||||
|
||||
TEST(Stringutils, DateTimeFromString)
|
||||
{
|
||||
EXPECT_EQ(fromISO8601String("2020-01-03T09:08:11.075"), (Wt::WDateTime{ Wt::WDate{ 2020, 01, 03 }, Wt::WTime{ 9, 8, 11, 75 } }));
|
||||
EXPECT_EQ(fromISO8601String("2020-01-03"), Wt::WDateTime{});
|
||||
EXPECT_EQ(fromISO8601String(""), Wt::WDateTime{});
|
||||
}
|
||||
|
||||
TEST(StringUtils, stringEndsWith)
|
||||
{
|
||||
EXPECT_TRUE(stringEndsWith("FooBar", "Bar"));
|
||||
|
||||
Reference in New Issue
Block a user