mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
display event year only if its not the current
This commit is contained in:
@@ -9,13 +9,21 @@ import org.joda.time.format.DateTimeFormatter;
|
|||||||
|
|
||||||
public class Formatter {
|
public class Formatter {
|
||||||
public static final String DAYCODE_PATTERN = "YYMMdd";
|
public static final String DAYCODE_PATTERN = "YYMMdd";
|
||||||
|
private static final String DAY_PATTERN = "d";
|
||||||
|
private static final String YEAR_PATTERN = "YYYY";
|
||||||
private static final String EVENT_DATE_PATTERN = "d YYYY"; // MMMM doesn't give the proper month name in some languages
|
private static final String EVENT_DATE_PATTERN = "d YYYY"; // MMMM doesn't give the proper month name in some languages
|
||||||
private static final String EVENT_TIME_PATTERN = "HH:mm";
|
private static final String EVENT_TIME_PATTERN = "HH:mm";
|
||||||
|
|
||||||
public static String getEventDate(Context context, String dayCode) {
|
public static String getEventDate(Context context, String dayCode) {
|
||||||
final String dayYear = getDateTimeFromCode(dayCode).toString(EVENT_DATE_PATTERN);
|
final DateTime dateTime = getDateTimeFromCode(dayCode);
|
||||||
|
final String day = dateTime.toString(DAY_PATTERN);
|
||||||
|
final String year = dateTime.toString(YEAR_PATTERN);
|
||||||
final int monthIndex = Integer.valueOf(dayCode.substring(2, 4)) - 1;
|
final int monthIndex = Integer.valueOf(dayCode.substring(2, 4)) - 1;
|
||||||
return getMonthName(context, monthIndex) + " " + dayYear;
|
final String month = getMonthName(context, monthIndex);
|
||||||
|
String date = month + " " + day;
|
||||||
|
if (!year.equals(new DateTime().toString(YEAR_PATTERN)))
|
||||||
|
date += " " + year;
|
||||||
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getEventDate(Context context, DateTime dateTime) {
|
public static String getEventDate(Context context, DateTime dateTime) {
|
||||||
|
Reference in New Issue
Block a user