aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/ui/Formatter.java
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-06-01 08:10:01 +0200
committerBananeweizen <bananeweizen@gmx.de>2012-06-01 08:10:01 +0200
commit47ff78ef9f780da1880b1997c68cf55f444b3f86 (patch)
tree246a3408ffc474c10b6cbafdf1b20688a6fd67f2 /main/src/cgeo/geocaching/ui/Formatter.java
parent55546fcc11cb011245566907651f93e1b25ff29a (diff)
downloadcgeo-47ff78ef9f780da1880b1997c68cf55f444b3f86.zip
cgeo-47ff78ef9f780da1880b1997c68cf55f444b3f86.tar.gz
cgeo-47ff78ef9f780da1880b1997c68cf55f444b3f86.tar.bz2
fix #1658: show today literally
Diffstat (limited to 'main/src/cgeo/geocaching/ui/Formatter.java')
-rw-r--r--main/src/cgeo/geocaching/ui/Formatter.java23
1 files changed, 22 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/ui/Formatter.java b/main/src/cgeo/geocaching/ui/Formatter.java
index 6ee1a65..33793c1 100644
--- a/main/src/cgeo/geocaching/ui/Formatter.java
+++ b/main/src/cgeo/geocaching/ui/Formatter.java
@@ -1,5 +1,6 @@
package cgeo.geocaching.ui;
+import cgeo.geocaching.R;
import cgeo.geocaching.cgeoapplication;
import android.content.Context;
@@ -64,9 +65,29 @@ public abstract class Formatter {
}
/**
+ * Generate a numeric date string according to system-wide settings (locale, date format)
+ * such as "10/20/2010". Today and yesterday will be presented as strings "today" and "yesterday".
+ *
+ * @param date
+ * milliseconds since the epoch
+ * @return the formatted string
+ */
+ public static String formatShortDateVerbally(long date) {
+ int diff = cgeo.geocaching.utils.DateUtils.daysSince(date);
+ switch (diff) {
+ case 0:
+ return cgeoapplication.getInstance().getString(R.string.log_today);
+ case 1:
+ return cgeoapplication.getInstance().getString(R.string.log_yesterday);
+ default:
+ return formatShortDate(date);
+ }
+ }
+
+ /**
* Generate a numeric date and time string according to system-wide settings (locale,
* date format) such as "7 sept. at 12:35".
- *
+ *
* @param context
* a Context
* @param date