mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-16 14:07:28 +01:00
Use separate string for toRelativeString "Today"
Apparently 0 quantity is ignored for some locales...
This commit is contained in:
@@ -6,6 +6,7 @@ import java.text.DateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
import java.util.TimeZone
|
||||
import kotlin.math.floor
|
||||
|
||||
fun Date.toDateTimestampString(dateFormatter: DateFormat): String {
|
||||
val date = dateFormatter.format(this)
|
||||
@@ -106,12 +107,13 @@ fun Date.toRelativeString(
|
||||
): String {
|
||||
val now = Date()
|
||||
val difference = now.time - this.time
|
||||
val days = difference / MILLISECONDS_IN_DAY
|
||||
val days = floor(difference / 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(
|
||||
R.plurals.relative_time,
|
||||
days.toInt(),
|
||||
days,
|
||||
days
|
||||
)
|
||||
else -> dateFormat.format(this)
|
||||
|
||||
Reference in New Issue
Block a user