From cf580292791b6583ecf0c0d9e085f2dd1f36362e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Feb 2026 04:37:51 +0000 Subject: [PATCH 1/3] Initial plan From 9e3e2b2c703cc03e35738885ad6499e4b5206f5a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Feb 2026 04:43:42 +0000 Subject: [PATCH 2/3] Add support for 'end of the week' and 'end of the month' expressions Co-authored-by: mihxil <429477+mihxil@users.noreply.github.com> --- src/main/antlr3/org/natty/generated/DateParser.g | 8 ++++++++ src/test/java/org/natty/grammar/DateGrammarTest.java | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/main/antlr3/org/natty/generated/DateParser.g b/src/main/antlr3/org/natty/generated/DateParser.g index de8ad2f3..5155ed66 100644 --- a/src/main/antlr3/org/natty/generated/DateParser.g +++ b/src/main/antlr3/org/natty/generated/DateParser.g @@ -461,6 +461,10 @@ explicit_relative_month_seek | THE WHITE_SPACE MONTH WHITE_SPACE AFTER WHITE_SPACE NEXT -> ^(SEEK DIRECTION[">"] SEEK_BY["by_day"] INT["2"] SPAN["month"]) + // the month (current month) + | THE WHITE_SPACE MONTH + -> ^(SEEK DIRECTION[">"] SEEK_BY["by_day"] INT["0"] SPAN["month"]) + // september | relaxed_month -> ^(SEEK DIRECTION[">"] SEEK_BY["by_day"] INT["0"] relaxed_month) @@ -486,6 +490,10 @@ explicit_relative_week_seek // the week after next | THE WHITE_SPACE WEEK WHITE_SPACE AFTER WHITE_SPACE NEXT -> ^(SEEK DIRECTION[">"] SEEK_BY["by_day"] INT["2"] SPAN["week"]) + + // the week (current week) + | THE WHITE_SPACE WEEK + -> ^(SEEK DIRECTION[">"] SEEK_BY["by_day"] INT["0"] SPAN["week"]) ; explicit_relative_fortnight_seek diff --git a/src/test/java/org/natty/grammar/DateGrammarTest.java b/src/test/java/org/natty/grammar/DateGrammarTest.java index c97b3466..0fad4a86 100644 --- a/src/test/java/org/natty/grammar/DateGrammarTest.java +++ b/src/test/java/org/natty/grammar/DateGrammarTest.java @@ -389,6 +389,18 @@ public void explicit_relative_date() throws Exception { assertAST("at the end of last month", "(RELATIVE_DATE (SEEK < by_week 1 month) (EXPLICIT_SEEK (DAY_OF_MONTH 31)))"); + assertAST("end of the week", + "(RELATIVE_DATE (SEEK > by_day 0 week) (EXPLICIT_SEEK (DAY_OF_WEEK 6)))"); + + assertAST("end of the month", + "(RELATIVE_DATE (SEEK > by_day 0 month) (EXPLICIT_SEEK (DAY_OF_MONTH 31)))"); + + assertAST("beginning of the week", + "(RELATIVE_DATE (SEEK > by_day 0 week) (EXPLICIT_SEEK (DAY_OF_WEEK 2)))"); + + assertAST("beginning of the month", + "(RELATIVE_DATE (SEEK > by_day 0 month) (EXPLICIT_SEEK (DAY_OF_MONTH 1)))"); + assertAST("the second day of april", "(RELATIVE_DATE (SEEK > by_day 0 (MONTH_OF_YEAR 4)) (EXPLICIT_SEEK (DAY_OF_MONTH 2)))"); From ddc845cc1888ce422dde9a85e398c31577b0eeca Mon Sep 17 00:00:00 2001 From: Michiel Meeuwissen Date: Mon, 23 Feb 2026 23:08:42 +0100 Subject: [PATCH 3/3] Added some more tests. --- src/test/java/org/natty/AbstractTest.java | 2 +- src/test/java/org/natty/DateTest.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/natty/AbstractTest.java b/src/test/java/org/natty/AbstractTest.java index 00d26184..931a82c5 100644 --- a/src/test/java/org/natty/AbstractTest.java +++ b/src/test/java/org/natty/AbstractTest.java @@ -50,7 +50,7 @@ protected List parseCollection(Date referenceDate, String value) { */ protected Date parseSingleDate(String value, Date referenceDate) { List dates = parseCollection(referenceDate, value); - Assert.assertEquals(1, dates.size()); + Assert.assertEquals("didn't find a date in '" + value + "' at all", 1, dates.size()); return dates.get(0); } diff --git a/src/test/java/org/natty/DateTest.java b/src/test/java/org/natty/DateTest.java index 05398546..7840cd76 100644 --- a/src/test/java/org/natty/DateTest.java +++ b/src/test/java/org/natty/DateTest.java @@ -175,6 +175,8 @@ public void testRelative() throws Exception { validateDate(reference, "1 year 9 months 1 day from now", 11, 29, 2012); validateDate(reference, "2 years 4 months ago", 10, 28, 2008); validateDate(reference, "2 years 4 months 5 days ago", 10, 23, 2008); + validateDate(reference, "end of the week", 3, 4, 2011); + validateDate(reference, "end of the month", 2, 28, 2011); } @Test