Fix today still being displayed even though relative time is off (#5732)
(cherry picked from commit 326d4c2641a37bb20fe1f43528d8b827a6c829d4)
This commit is contained in:
parent
ac75ad7489
commit
8da397c7ed
1 changed files with 5 additions and 0 deletions
|
|
@ -105,6 +105,9 @@ fun Date.toRelativeString(
|
||||||
range: Int = 7,
|
range: Int = 7,
|
||||||
dateFormat: DateFormat = DateFormat.getDateInstance(DateFormat.SHORT)
|
dateFormat: DateFormat = DateFormat.getDateInstance(DateFormat.SHORT)
|
||||||
): String {
|
): String {
|
||||||
|
if (range == 0) {
|
||||||
|
return dateFormat.format(this)
|
||||||
|
}
|
||||||
val now = Date()
|
val now = Date()
|
||||||
val difference = now.time - this.time
|
val difference = now.time - this.time
|
||||||
val days = floor(difference / MILLISECONDS_IN_DAY).toInt()
|
val days = floor(difference / MILLISECONDS_IN_DAY).toInt()
|
||||||
|
|
@ -119,3 +122,5 @@ fun Date.toRelativeString(
|
||||||
else -> dateFormat.format(this)
|
else -> dateFormat.format(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue