fix(events): show the venue-local concert time consistently
Backend sent the UTC `dateTime` (a 20:00 local show read as 08:00Z), and Android's ZonedDateTime.parse choked on zone-less values → some rows had a wrong time, others none at all. - Backend: prefer localDate+localTime (venue-local, naive) over the UTC instant. - Android: parse a naive LocalDateTime first, fall back to ZonedDateTime for older "…Z" values. Web already renders the naive string as-is. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
f27eaf9c82
commit
2208ce77b6
2 files changed
+15
-6
No files matched your search
@@ -21,6 +21,7 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.novasonic.app.api.model.ConcertEvent
|
||||
import com.novasonic.app.ui.theme.*
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZonedDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.Locale
|
||||
@@ -165,12 +166,17 @@ private fun EventRow(event: ConcertEvent, onTicketClick: (String) -> Unit) {
|
||||
}
|
||||
}
|
||||
|
||||
private val DATE_FMT = DateTimeFormatter.ofPattern("dd. MMM yyyy", Locale.GERMAN)
|
||||
private val TIME_FMT = DateTimeFormatter.ofPattern("HH:mm")
|
||||
|
||||
private fun formatEventDateTime(datetime: String): Pair<String, String> {
|
||||
return try {
|
||||
val zdt = ZonedDateTime.parse(datetime)
|
||||
val date = zdt.format(DateTimeFormatter.ofPattern("dd. MMM yyyy", Locale.GERMAN))
|
||||
val time = if (zdt.hour == 0 && zdt.minute == 0) ""
|
||||
else zdt.format(DateTimeFormatter.ofPattern("HH:mm"))
|
||||
// Backend now sends a naive venue-local datetime ("2026-09-16T20:00:00"); older/zoned
|
||||
// values ("…Z") still parse via the ZonedDateTime fallback.
|
||||
val ldt = runCatching { LocalDateTime.parse(datetime) }
|
||||
.getOrElse { ZonedDateTime.parse(datetime).toLocalDateTime() }
|
||||
val date = ldt.format(DATE_FMT)
|
||||
val time = if (ldt.hour == 0 && ldt.minute == 0) "" else ldt.format(TIME_FMT)
|
||||
date to time
|
||||
} catch (_: Exception) {
|
||||
datetime.take(10) to ""
|
||||
|
||||
Reference in new issue
Block a user