Check new date format in items.

This commit is contained in:
davidoskky 2021-03-19 17:24:25 +01:00
parent 5b70ae138e
commit f4f8503037

View File

@ -21,8 +21,14 @@ fun String.toTextDrawableString(c: Context): String {
fun Item.sourceAndDateText(): String { fun Item.sourceAndDateText(): String {
val formattedDate: String = try { val formattedDate: String = try {
var date = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(this.datetime)
// Api 3.0 changes the date format, check for ISO8601 format
if (date == null) {
date = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX").parse(this.datetime)
}
" " + DateUtils.getRelativeTimeSpanString( " " + DateUtils.getRelativeTimeSpanString(
SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(this.datetime).time, date.time,
Date().time, Date().time,
DateUtils.MINUTE_IN_MILLIS, DateUtils.MINUTE_IN_MILLIS,
DateUtils.FORMAT_ABBREV_RELATIVE DateUtils.FORMAT_ABBREV_RELATIVE