Remove humanised datetime formatting

Year is not shown if it's same as the current year.
This commit is contained in:
Naveen 2022-10-14 00:37:03 +05:30
parent 203f10618f
commit f721754785
2 changed files with 14 additions and 12 deletions

View file

@ -1,19 +1,8 @@
package com.simplemobiletools.smsmessenger.extensions
import android.content.Context
import android.text.format.DateFormat
import android.text.format.DateUtils
import org.joda.time.DateTime
import java.util.*
fun Date.format(pattern: String): String {
return DateFormat.format(pattern, this).toString()
}
fun DateTime.humanize(context: Context, now: DateTime = DateTime.now(), pattern: String = "EEE, MMM dd, YYYY, hh:mm a"): String {
return if (yearOfCentury().get() > now.yearOfCentury().get()) {
toString(pattern)
} else {
DateUtils.getRelativeDateTimeString(context, millis, DateUtils.SECOND_IN_MILLIS, DateUtils.DAY_IN_MILLIS, 0).toString()
}
}