Format the "updated" timestamp as a locale-aware date/time

Replaces the raw "2026-09-10 10:03:54" with each platform's own
locale-formatted, no-seconds rendering (e.g. "Sep 10, 2026, 10:03 AM"
in en-US) — mirroring how amounts are already locale-formatted
elsewhere (NumberFormat.kt). Android uses the pre-java.time
Calendar/DateFormat APIs since minSdk 24 predates java.time (API 26)
and the project has no core library desugaring configured.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FXcrACM5sok3M1KQJ8kByy
This commit is contained in:
2026-09-10 11:57:19 +03:00
co-authored by Claude Sonnet 5
parent 43b66b6665
commit 3ce3bab7c6
6 changed files with 87 additions and 4 deletions
@@ -0,0 +1,11 @@
package xyz.tyiu.satsprice.domain
import kotlinx.datetime.LocalDateTime
/**
* A locale-aware, human-readable rendering of [dateTime] (e.g. "Sep 10, 2026, 10:03 AM" in
* en-US), using each platform's own date/time formatter — mirroring how [localizedGroupedInteger]
* and [localizedDecimalSeparator] format numbers. Deliberately drops seconds: a "last updated"
* label doesn't need second-level precision.
*/
expect fun localizedDateTime(dateTime: LocalDateTime): String
@@ -5,6 +5,7 @@ import kotlinx.datetime.toLocalDateTime
import xyz.tyiu.satsprice.CurrencyInfo
import xyz.tyiu.satsprice.domain.CurrencyConverter
import xyz.tyiu.satsprice.domain.formatAmount
import xyz.tyiu.satsprice.domain.localizedDateTime
import xyz.tyiu.satsprice.domain.toBigDecimalOrNull
import kotlin.time.Instant
@@ -52,7 +53,5 @@ fun ConverterUiState.unselectedCurrencies(): List<CurrencyInfo> =
/** Whether the active price source quotes a rate for [code] — every currency is listed regardless. */
fun ConverterUiState.isPriced(code: String): Boolean = code in pricedCurrencyCodes
private fun Instant.toDateTimeString(): String {
val local = toLocalDateTime(TimeZone.currentSystemDefault())
return local.toString().substringBefore('.').replace('T', ' ')
}
private fun Instant.toDateTimeString(): String =
localizedDateTime(toLocalDateTime(TimeZone.currentSystemDefault()))