Remove relative timestamps setting

This commit is contained in:
arkon
2023-07-29 10:03:16 -04:00
parent 3892c4caac
commit fe90546821
12 changed files with 10 additions and 52 deletions

View File

@@ -114,19 +114,15 @@ private const val MILLISECONDS_IN_DAY = 86_400_000L
fun Date.toRelativeString(
context: Context,
range: Int = 7,
dateFormat: DateFormat = DateFormat.getDateInstance(DateFormat.SHORT),
): String {
if (range == 0) {
return dateFormat.format(this)
}
val now = Date()
val difference = now.timeWithOffset.floorNearest(MILLISECONDS_IN_DAY) - this.timeWithOffset.floorNearest(MILLISECONDS_IN_DAY)
val days = difference.floorDiv(MILLISECONDS_IN_DAY).toInt()
return when {
difference < 0 -> context.getString(R.string.recently)
difference < MILLISECONDS_IN_DAY -> context.getString(R.string.relative_time_today)
difference < MILLISECONDS_IN_DAY.times(range) -> context.resources.getQuantityString(
difference < MILLISECONDS_IN_DAY.times(7) -> context.resources.getQuantityString(
R.plurals.relative_time,
days,
days,