Merge pull request #1200 from owncloud/fix_1192_date_time

fix for #1192
This commit is contained in:
Maria Asensio 2015-10-30 10:38:14 +01:00
commit 4a11470630

View file

@ -193,22 +193,19 @@ public class DisplayUtils {
else if ((System.currentTimeMillis() - time) < 60 * 1000) {
return c.getString(R.string.file_list_seconds_ago);
} else {
// Workaround 2.x bug (see https://github.com/owncloud/android/issues/716)
if ( Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB &&
(System.currentTimeMillis() - time) > 24 * 60 * 60 * 1000 ) {
Date date = new Date(time);
date.setHours(0);
date.setMinutes(0);
date.setSeconds(0);
dateString = DateUtils.getRelativeDateTimeString(
c, date.getTime(), minResolution, transitionResolution, flags
);
} else {
dateString = DateUtils.getRelativeDateTimeString(c, time, minResolution, transitionResolution, flags);
dateString = DateUtils.getRelativeDateTimeString(c, time, minResolution, transitionResolution, flags);
}
String[] parts = dateString.toString().split(",");
if (parts.length == 2) {
if (parts[1].contains(":") && !parts[0].contains(":")) {
return parts[0];
} else if (parts[0].contains(":") && !parts[1].contains(":")) {
return parts[1];
}
}
return dateString.toString().split(",")[0];
//dateString contains unexpected format. fallback: use relative date time string from android api as is.
return dateString.toString();
}
/**