From c3a7708f8cd4c3b887a6045f64c83a83bac69558 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Feb 2026 12:22:07 +0000 Subject: [PATCH 1/2] Initial plan From 5a45eab8d1c84406404def8ed6639cd38d6c4fdd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Feb 2026 12:29:55 +0000 Subject: [PATCH 2/2] Add support for After/Before The Weekend expressions Co-authored-by: mihxil <429477+mihxil@users.noreply.github.com> --- src/main/antlr3/org/natty/generated/DateParser.g | 12 ++++++++++++ src/test/java/org/natty/DateTest.java | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/src/main/antlr3/org/natty/generated/DateParser.g b/src/main/antlr3/org/natty/generated/DateParser.g index de8ad2f..a1f9d53 100644 --- a/src/main/antlr3/org/natty/generated/DateParser.g +++ b/src/main/antlr3/org/natty/generated/DateParser.g @@ -418,6 +418,18 @@ relative_date | (THE WHITE_SPACE)? relative_date_span WHITE_SPACE AFTER WHITE_SPACE NEXT -> ^(RELATIVE_DATE ^(SEEK DIRECTION[">"] SEEK_BY["by_day"] INT["2"] relative_date_span)) + // after the weekend -> next monday + // Note: "weekend" is lexed as SATURDAY token (see DateLexer.g); the result is the + // Monday following the upcoming weekend, matching "after the weekend" semantics. + | AFTER WHITE_SPACE THE WHITE_SPACE SATURDAY + -> ^(RELATIVE_DATE ^(SEEK DIRECTION[">"] SEEK_BY["by_day"] INT["1"] ^(DAY_OF_WEEK INT["2"]))) + + // before the weekend -> next friday + // Note: "weekend" is lexed as SATURDAY token (see DateLexer.g); the result is the + // Friday immediately preceding the upcoming weekend. + | BEFORE WHITE_SPACE THE WHITE_SPACE SATURDAY + -> ^(RELATIVE_DATE ^(SEEK DIRECTION[">"] SEEK_BY["by_day"] INT["1"] ^(DAY_OF_WEEK INT["6"]))) + // today, tomorrow | named_relative_date diff --git a/src/test/java/org/natty/DateTest.java b/src/test/java/org/natty/DateTest.java index 0539854..1855a12 100644 --- a/src/test/java/org/natty/DateTest.java +++ b/src/test/java/org/natty/DateTest.java @@ -110,6 +110,12 @@ public void testRelative() throws Exception { validateDate(reference, "4 mondays from now", 3, 28, 2011); validateDate(reference, "4 mondays from today", 3, 28, 2011); validateDate(reference, "next weekend", 3, 12, 2011); + // "after the weekend" returns the Monday following the upcoming weekend (Mar 5-6) + validateDate(reference, "after the weekend", 3, 7, 2011); + validateDate(reference, "After The Weekend", 3, 7, 2011); + // "before the weekend" returns the Friday immediately before the upcoming weekend (Mar 5-6) + validateDate(reference, "before the weekend", 3, 4, 2011); + validateDate(reference, "Before The Weekend", 3, 4, 2011); validateDate(reference, "six mondays ago", 1, 17, 2011); validateDate(reference, "last monday", 2, 21, 2011); validateDate(reference, "last mon", 2, 21, 2011);