From d6db97c0057f15474e16a1ee78f85ef20d8c527a Mon Sep 17 00:00:00 2001 From: rsudev Date: Tue, 4 Jun 2013 22:36:35 +0200 Subject: Fixes #2833, website changes 2013-06-02 Get custom dateformat from login Use it for posting logs --- main/src/cgeo/geocaching/connector/gc/GCParser.java | 5 +++-- main/src/cgeo/geocaching/connector/gc/Login.java | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java index b2705b2..6b456fd 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCParser.java +++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java @@ -54,6 +54,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.EnumSet; +import java.util.GregorianCalendar; import java.util.List; import java.util.Locale; import java.util.Set; @@ -972,7 +973,7 @@ public abstract class GCParser { "__EVENTARGUMENT", "", "__LASTFOCUS", "", "ctl00$ContentBody$LogBookPanel1$ddLogType", Integer.toString(logType.id), - "ctl00$ContentBody$LogBookPanel1$uxDateVisited", String.format("%02d", month) + "/" + String.format("%02d", day) + "/" + String.format("%04d", year), + "ctl00$ContentBody$LogBookPanel1$uxDateVisited", Login.getCustomGcDateFormat().format(new GregorianCalendar(year, month - 1, day).getTime()), "ctl00$ContentBody$LogBookPanel1$uxDateVisited$Month", Integer.toString(month), "ctl00$ContentBody$LogBookPanel1$uxDateVisited$Day", Integer.toString(day), "ctl00$ContentBody$LogBookPanel1$uxDateVisited$Year", Integer.toString(year), @@ -1168,7 +1169,7 @@ public abstract class GCParser { params.put("ctl00$ContentBody$LogBookPanel1$uxDateVisited", ""); } else { params.put("ctl00$ContentBody$LogBookPanel1$DateTimeLogged", Integer.toString(month) + "/" + Integer.toString(day) + "/" + Integer.toString(year)); - params.put("ctl00$ContentBody$LogBookPanel1$uxDateVisited", Integer.toString(month) + "/" + Integer.toString(day) + "/" + Integer.toString(year)); + params.put("ctl00$ContentBody$LogBookPanel1$uxDateVisited", Login.getCustomGcDateFormat().format(new GregorianCalendar(year, month - 1, day).getTime())); } params.put( "ctl00$ContentBody$LogBookPanel1$DateTimeLogged$Day", Integer.toString(day), diff --git a/main/src/cgeo/geocaching/connector/gc/Login.java b/main/src/cgeo/geocaching/connector/gc/Login.java index f3ef290..7351311 100644 --- a/main/src/cgeo/geocaching/connector/gc/Login.java +++ b/main/src/cgeo/geocaching/connector/gc/Login.java @@ -328,6 +328,15 @@ public abstract class Login { return parseGcCustomDate(input, Settings.getGcCustomDate()); } + public static SimpleDateFormat getCustomGcDateFormat() { + final String format = Settings.getGcCustomDate(); + if (gcCustomDateFormats.containsKey(format)) { + return gcCustomDateFormats.get(format); + } + + return gcCustomDateFormats.get("MM/dd/yyyy"); + } + /** * checks if an Array of Strings is empty or not. Empty means: * - Array is null -- cgit v1.1