diff --git a/src/libs/core/impl/PartialDateTime.cpp b/src/libs/core/impl/PartialDateTime.cpp index a2943944..1d88c3f7 100644 --- a/src/libs/core/impl/PartialDateTime.cpp +++ b/src/libs/core/impl/PartialDateTime.cpp @@ -66,6 +66,9 @@ namespace lms::core "%Y-%m-%dT%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) diff --git a/src/libs/core/test/PartialDateTime.cpp b/src/libs/core/test/PartialDateTime.cpp index 3afd4dac..cd5b1fc1 100644 --- a/src/libs/core/test/PartialDateTime.cpp +++ b/src/libs/core/test/PartialDateTime.cpp @@ -87,23 +87,34 @@ namespace lms::core::stringUtils::tests }; constexpr TestCase tests[]{ + { "", "" }, + { "aaaa", "" }, + { "aaaa-bb", "" }, { "1992", "1992" }, { "1992-03", "1992-03" }, + { "1992-00", "1992" }, + { "1992-03-00", "1992-03" }, { "1992-03-27", "1992-03-27" }, + { "1992-00-00", "1992" }, { "1992-03-27T15", "1992-03-27T15" }, { "1992-03-27T15:08", "1992-03-27T15:08" }, { "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:08", "1992-03-27T15:08" }, { "1992-03-27 15:08:57", "1992-03-27T15:08:57" }, + { "aaaa/bb", "" }, { "1992", "1992" }, + { "1992/00", "1992" }, { "1992/03", "1992-03" }, + { "1992/03/00", "1992-03" }, { "1992/03/27", "1992-03-27" }, { "1992/03/27 15", "1992-03-27T15" }, { "1992/03/27 15:08", "1992-03-27T15:08" }, { "1992/03/27 15:08:57", "1992-03-27T15:08:57" }, + { "1992/03/00 15:08:57", "1992-03" }, }; for (const TestCase& test : tests)