aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/connector/gc
diff options
context:
space:
mode:
authorcampbeb <bpcampbell@gmail.com>2012-06-09 10:43:01 +0900
committercampbeb <bpcampbell@gmail.com>2012-06-09 10:43:01 +0900
commit262af5cb074233bde0f5503659056727f89d6280 (patch)
tree622c5b82b71b5a2913a2bbfee491b4c768bfb465 /main/src/cgeo/geocaching/connector/gc
parentb335983a2a9ceef86af0d60ced2cd84397899281 (diff)
downloadcgeo-262af5cb074233bde0f5503659056727f89d6280.zip
cgeo-262af5cb074233bde0f5503659056727f89d6280.tar.gz
cgeo-262af5cb074233bde0f5503659056727f89d6280.tar.bz2
Parse cache found date
This is required before we are able to sort by date logged/visited.
Diffstat (limited to 'main/src/cgeo/geocaching/connector/gc')
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCConstants.java1
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCParser.java11
2 files changed, 12 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/connector/gc/GCConstants.java b/main/src/cgeo/geocaching/connector/gc/GCConstants.java
index ae62b33..c280c74 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCConstants.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCConstants.java
@@ -40,6 +40,7 @@ public final class GCConstants {
public final static Pattern PATTERN_OWNER_USERID = Pattern.compile("<a id=\"ctl00_ContentBody_uxFindLinksHiddenByThisUser\" href=\"[^\"]*/seek/nearest\\.aspx\\?u=(.*?)\"");
public final static Pattern PATTERN_FOUND = Pattern.compile("<a id=\"ctl00_ContentBody_hlFoundItLog\"[^<]*<img src=\".*/images/stockholm/16x16/check\\.gif\"[^>]*>[^<]*</a>[^<]*</p>");
public final static Pattern PATTERN_FOUND_ALTERNATIVE = Pattern.compile("<div class=\"StatusInformationWidget FavoriteWidget\"");
+ public final static Pattern PATTERN_FOUND_DATE = Pattern.compile("You logged this as Found on ([^.]+?)\\.[^<]*</a>[^<]*</p>");
public final static Pattern PATTERN_OWNER_DISPLAYNAME = Pattern.compile("<div id=\"ctl00_ContentBody_mcd1\">[^<]+<a href=\"[^\"]+\">([^<]+)</a></div>");
public final static Pattern PATTERN_TYPE = Pattern.compile("<img src=\"[^\"]*/WptTypes/\\d+\\.gif\" alt=\"([^\"]+?)\" title=\"[^\"]+\" width=\"32\" height=\"32\"");
public final static Pattern PATTERN_HIDDEN = Pattern.compile("<div id=\"ctl00_ContentBody_mcd2\">\\W*Hidden[\\s:]*([^<]+?)</div>");
diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java
index 77e26a4..26aa7ad 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCParser.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java
@@ -439,6 +439,17 @@ public abstract class GCParser {
// cache found
cache.setFound(BaseUtils.matches(page, GCConstants.PATTERN_FOUND) || BaseUtils.matches(page, GCConstants.PATTERN_FOUND_ALTERNATIVE));
+ // cache found date
+ try {
+ final String foundDateString = BaseUtils.getMatch(page, GCConstants.PATTERN_FOUND_DATE, true, null);
+ if (StringUtils.isNotBlank(foundDateString)) {
+ cache.setVisitedDate(Login.parseGcCustomDate(foundDateString).getTime());
+ }
+ } catch (ParseException e) {
+ // failed to parse cache found date
+ Log.w("GCParser.parseCache: Failed to parse cache found date");
+ }
+
// cache type
cache.setType(CacheType.getByPattern(BaseUtils.getMatch(page, GCConstants.PATTERN_TYPE, true, cache.getType().id)));