Skip to content

Commit

Permalink
[WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
vkhrystiuk-ks committed Jan 2, 2025
1 parent 0f823b9 commit b14efe5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/main/java/liqp/filters/date/fuzzy/FuzzyDateParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
* https://en.wikipedia.org/wiki/Date_format_by_country
* https://en.wikipedia.org/wiki/Date_and_time_notation_in_Germany
* https://en.wikipedia.org/wiki/Date_and_time_representation_by_country
*
* author: Vasyl Khrystiuk
*/
public class FuzzyDateParser extends BasicDateParser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{
{null, " 11 december 11", RuntimeException.class},
{null, " 11 -december- 11", RuntimeException.class},
{null, "december - monday 11 2024", RuntimeException.class}, // numbers should not be leftover
});
}

Expand All @@ -37,8 +38,8 @@ public FuzzyDateParserParametrizedErrorsTest(Locale locale, String input, Class
public void shouldParse() {
try {
final FuzzyDateParser parser = new FuzzyDateParser();
parser.guessPattern(input, locale, null);
fail(String.format("input is: [%s] and should be wrong", input));
String pattern = parser.guessPattern(input, locale, null).pattern;
fail(String.format("input is: [%s] and should be wrong but was recognized as [%s]", input, pattern));
} catch (Exception e) {
if (!exceptionClass.isInstance(e)) {
fail(String.format("for input %s exception class should be %s, but it was %s instead", input, exceptionClass, e.getClass()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ public static Collection<Object[]> data() {
{null, "december.31st", "MMMM.dd"},
{null, " 11 december, 11 ", " dd MMMM, '11' "},
{null, " 11, december 11 ", " '11', MMMM dd "},
{null, " 11 december - 11 ", " dd MMMM - '11' "},
{null, " 11 - december 11 ", " '11' - MMMM dd "},
{null, " 11 , december - 11 ", " '11' , MMMM - dd "},
{null, " 11 - december , 11 ", " dd - MMMM , '11' "},
{null, "11 december, 11", "dd MMMM, '11'"},
{null, "11, december 11", "'11', MMMM dd"},
{null, "11 december - 11", "dd MMMM - '11'"},
{null, "11 - december 11", "'11' - MMMM dd"},
{null, "11 , december - 11", "'11' , MMMM - dd"},
{null, "11 - december , 11", "dd - MMMM , '11'"},

{null, "december - 11", "MMMM - dd"}

});
}

Expand Down

0 comments on commit b14efe5

Please sign in to comment.