Increased sophistication of displaying due dates in task adapter, it was displaying next week incorrectly

pull/14/head
Tim Su 13 years ago
parent 513e2eda89
commit 8a0b6f1a61

@ -111,11 +111,18 @@ public class DateUtilities {
*/ */
@SuppressWarnings("nls") @SuppressWarnings("nls")
public static String getDateStringWithWeekday(Context context, Date date) { public static String getDateStringWithWeekday(Context context, Date date) {
String weekday = DateUtils.getDayOfWeekString(date.getDay() + Calendar.SUNDAY, String weekday = getWeekday(date);
DateUtils.LENGTH_LONG);
return weekday + ", " + getDateString(context, date); return weekday + ", " + getDateString(context, date);
} }
/**
* @return weekday
*/
public static String getWeekday(Date date) {
return DateUtils.getDayOfWeekString(date.getDay() + Calendar.SUNDAY,
DateUtils.LENGTH_LONG);
}
/** /**
* @return date format as getDateFormat with weekday * @return date format as getDateFormat with weekday
*/ */

@ -483,10 +483,14 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
else else
string = DateUtilities.getRelativeDay(activity, date).toLowerCase(); string = DateUtilities.getRelativeDay(activity, date).toLowerCase();
} else { } else {
string = DateUtils.getRelativeDateTimeString(activity, date, if(Task.hasDueTime(date))
DateUtils.MINUTE_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0).toString(); string = DateUtils.getRelativeDateTimeString(activity, date,
if(!Task.hasDueTime(date)) DateUtils.MINUTE_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0).toString();
string = string.substring(0, string.lastIndexOf(',')); else if(Math.abs(date - DateUtilities.now()) < DateUtilities.ONE_WEEK)
string = DateUtilities.getWeekday(new Date(date));
else
string = DateUtilities.getDateString(activity, new Date(date));
} }
dateCache.put(date, string); dateCache.put(date, string);

Loading…
Cancel
Save