Properly exclude 00 for partial dates, fixes #477

This commit is contained in:
emeric
2025-01-20 13:43:19 +01:00
parent 33759def78
commit 817588a755
2 changed files with 14 additions and 0 deletions
+3
View File
@@ -66,6 +66,9 @@ namespace lms::core
"%Y-%m-%dT%H:%M:%S", "%Y-%m-%dT%H:%M:%S",
"%Y-%m-%d %H:%M:%S", "%Y-%m-%d %H:%M:%S",
"%Y/%m/%d %H:%M:%S", "%Y/%m/%d %H:%M:%S",
"%Y-%m",
"%Y/%m",
"%Y",
}; };
for (const char* format : formats) for (const char* format : formats)
+11
View File
@@ -87,23 +87,34 @@ namespace lms::core::stringUtils::tests
}; };
constexpr TestCase tests[]{ constexpr TestCase tests[]{
{ "", "" },
{ "aaaa", "" },
{ "aaaa-bb", "" },
{ "1992", "1992" }, { "1992", "1992" },
{ "1992-03", "1992-03" }, { "1992-03", "1992-03" },
{ "1992-00", "1992" },
{ "1992-03-00", "1992-03" },
{ "1992-03-27", "1992-03-27" }, { "1992-03-27", "1992-03-27" },
{ "1992-00-00", "1992" },
{ "1992-03-27T15", "1992-03-27T15" }, { "1992-03-27T15", "1992-03-27T15" },
{ "1992-03-27T15:08", "1992-03-27T15:08" }, { "1992-03-27T15:08", "1992-03-27T15:08" },
{ "1992-03-27T15:08:57", "1992-03-27T15:08:57" }, { "1992-03-27T15:08:57", "1992-03-27T15:08:57" },
{ "1992-03-00T15:08:57", "1992-03" },
{ "1992-03-27 15", "1992-03-27T15" }, { "1992-03-27 15", "1992-03-27T15" },
{ "1992-03-27 15:08", "1992-03-27T15:08" }, { "1992-03-27 15:08", "1992-03-27T15:08" },
{ "1992-03-27 15:08:57", "1992-03-27T15:08:57" }, { "1992-03-27 15:08:57", "1992-03-27T15:08:57" },
{ "aaaa/bb", "" },
{ "1992", "1992" }, { "1992", "1992" },
{ "1992/00", "1992" },
{ "1992/03", "1992-03" }, { "1992/03", "1992-03" },
{ "1992/03/00", "1992-03" },
{ "1992/03/27", "1992-03-27" }, { "1992/03/27", "1992-03-27" },
{ "1992/03/27 15", "1992-03-27T15" }, { "1992/03/27 15", "1992-03-27T15" },
{ "1992/03/27 15:08", "1992-03-27T15:08" }, { "1992/03/27 15:08", "1992-03-27T15:08" },
{ "1992/03/27 15:08:57", "1992-03-27T15:08:57" }, { "1992/03/27 15:08:57", "1992-03-27T15:08:57" },
{ "1992/03/00 15:08:57", "1992-03" },
}; };
for (const TestCase& test : tests) for (const TestCase& test : tests)