diff --git a/src/main/java/plato/parser/DateHandler.java b/src/main/java/plato/parser/DateHandler.java index 30eea08df6..6bc908ab81 100644 --- a/src/main/java/plato/parser/DateHandler.java +++ b/src/main/java/plato/parser/DateHandler.java @@ -61,6 +61,11 @@ public static Optional checkDate(String testDate) throws PlatoExcepti * @return An Optional that contains LocalTime if it exists. */ public static Optional checkTime(String testTime) throws PlatoException { + //Remove the date so that it is easier to check for the time, and prevent conflicts + Matcher removeDate = PATTERN_DATE.matcher(testTime); + if (removeDate.find()) { + testTime = testTime.replaceAll(removeDate.group(), ""); + } Matcher match = TIME_PATTERN.matcher(testTime); Matcher am = Pattern.compile("(?i)[ap]m").matcher(testTime); diff --git a/src/test/java/plato/parser/DateHandlerTest.java b/src/test/java/plato/parser/DateHandlerTest.java index 6c679a22a5..368af09353 100644 --- a/src/test/java/plato/parser/DateHandlerTest.java +++ b/src/test/java/plato/parser/DateHandlerTest.java @@ -20,4 +20,9 @@ public void check_date_success() throws PlatoException { public void checkTime_success() throws PlatoException { assertEquals(LocalTime.of(18, 0), DateHandler.checkTime("1800 12-04-23").orElse(LocalTime.of(0, 0))); } + + @Test + public void checkTime_dateyearfull_success() throws PlatoException { + assertEquals(LocalTime.of(23, 59), DateHandler.checkTime("2359 15/02/2024").orElse(LocalTime.of(0, 0))); + } }