From aa33a5cf8e55609c9eec52ef947cad8f7220307b Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Sat, 21 Feb 2015 06:59:37 +0100 Subject: better event start time detection --- main/res/values/changelog_master.xml | 1 + main/src/cgeo/geocaching/Geocache.java | 6 +++--- tests/src/cgeo/geocaching/GeocacheTest.java | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/main/res/values/changelog_master.xml b/main/res/values/changelog_master.xml index a01610e..51cf8f9 100644 --- a/main/res/values/changelog_master.xml +++ b/main/res/values/changelog_master.xml @@ -14,6 +14,7 @@ · New: Allow export of waypoints without coords to Locus\n · New: Confirmation on backup/restore\n · New: Links in personal notes can be clicked\n + · Fix: Improve detection pattern for event start time\n · Fix: Don\'t allow logs in the future\n · Fix: Allow shortcut creation for All caches list\n · Fix: Some menus not available when invoking map from compass\n diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java index e87495f..e2eed56 100644 --- a/main/src/cgeo/geocaching/Geocache.java +++ b/main/src/cgeo/geocaching/Geocache.java @@ -24,8 +24,8 @@ import cgeo.geocaching.list.StoredList; import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.network.HtmlImage; import cgeo.geocaching.settings.Settings; -import cgeo.geocaching.utils.CancellableHandler; import cgeo.geocaching.utils.CalendarUtils; +import cgeo.geocaching.utils.CancellableHandler; import cgeo.geocaching.utils.ImageUtils; import cgeo.geocaching.utils.LazyInitializedList; import cgeo.geocaching.utils.Log; @@ -1646,7 +1646,7 @@ public class Geocache implements IWaypoint { // 17 - 20 o'clock patterns.add(Pattern.compile("\\b(\\d{1,2})(?:\\.00)?" + "\\s*(?:-|[a-z]+)\\s*" + "(?:\\d{1,2})(?:\\.00)?" + "\\s+" + Pattern.quote(hourLocalized), Pattern.CASE_INSENSITIVE)); // 12 o'clock, 12.00 o'clock - patterns.add(Pattern.compile("\\b(\\d{1,2})(?:\\.00)?\\s+" + Pattern.quote(hourLocalized), Pattern.CASE_INSENSITIVE)); + patterns.add(Pattern.compile("\\b(\\d{1,2})(?:\\.(00|15|30|45))?\\s+" + Pattern.quote(hourLocalized), Pattern.CASE_INSENSITIVE)); } final String searchText = getShortDescription() + ' ' + getDescription(); @@ -1656,7 +1656,7 @@ public class Geocache implements IWaypoint { try { final int hours = Integer.parseInt(matcher.group(1)); int minutes = 0; - if (matcher.groupCount() >= 2) { + if (matcher.groupCount() >= 2 && !StringUtils.isEmpty(matcher.group(2))) { minutes = Integer.parseInt(matcher.group(2)); } if (hours >= 0 && hours < 24 && minutes >= 0 && minutes < 60) { diff --git a/tests/src/cgeo/geocaching/GeocacheTest.java b/tests/src/cgeo/geocaching/GeocacheTest.java index 3e29bcf..26c677d 100644 --- a/tests/src/cgeo/geocaching/GeocacheTest.java +++ b/tests/src/cgeo/geocaching/GeocacheTest.java @@ -295,6 +295,7 @@ public class GeocacheTest extends CGeoTestCase { assertTime("Uhrzeit: 17-20 " + timeHours + "", 17, 00); assertTime("von 11 bis 13 " + timeHours, 11, 00); assertTime("from 11 to 13 " + timeHours, 11, 00); + assertTime("von 19.15 " + timeHours + " bis ca.20.30 " + timeHours + " statt", 19, 15); } public static void testGuessEventTimeShortDescription() { -- cgit v1.1