ui: use .seconds instead of .toDuration
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
d6ad7d11d0
commit
e2f931b4cb
@ -14,8 +14,8 @@ import android.os.Build
|
|||||||
import com.wireguard.android.Application
|
import com.wireguard.android.Application
|
||||||
import com.wireguard.android.R
|
import com.wireguard.android.R
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
import kotlin.time.DurationUnit
|
import kotlin.time.DurationUnit
|
||||||
import kotlin.time.toDuration
|
|
||||||
|
|
||||||
object QuantityFormatter {
|
object QuantityFormatter {
|
||||||
fun formatBytes(bytes: Long): String {
|
fun formatBytes(bytes: Long): String {
|
||||||
@ -33,7 +33,7 @@ object QuantityFormatter {
|
|||||||
var span = (System.currentTimeMillis() - epochMillis) / 1000
|
var span = (System.currentTimeMillis() - epochMillis) / 1000
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
|
||||||
return Application.get().applicationContext.getString(R.string.latest_handshake_ago, span.toDuration(DurationUnit.SECONDS).toString())
|
return Application.get().applicationContext.getString(R.string.latest_handshake_ago, span.seconds.toString())
|
||||||
|
|
||||||
if (span <= 0L)
|
if (span <= 0L)
|
||||||
return RelativeDateTimeFormatter.getInstance().format(RelativeDateTimeFormatter.Direction.PLAIN, RelativeDateTimeFormatter.AbsoluteUnit.NOW)
|
return RelativeDateTimeFormatter.getInstance().format(RelativeDateTimeFormatter.Direction.PLAIN, RelativeDateTimeFormatter.AbsoluteUnit.NOW)
|
||||||
|
Loading…
Reference in New Issue
Block a user