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 ""
|
||||
|
||||
@@ -393,9 +393,12 @@ app.get('/api/events/:artist', (req, res) => {
|
||||
const events = raw.map(e => {
|
||||
const venue = e._embedded?.venues?.[0] || {};
|
||||
const start = e.dates?.start || {};
|
||||
const dt = start.dateTime || (start.localDate
|
||||
// Prefer the venue-LOCAL date/time (localDate + localTime) over the UTC `dateTime` —
|
||||
// otherwise a 20:00 local show is shown as its 08:00Z UTC instant. Sent as a naive local
|
||||
// datetime string (no zone); the clients render it as-is.
|
||||
const dt = (start.localDate
|
||||
? `${start.localDate}T${start.localTime || '00:00:00'}`
|
||||
: null);
|
||||
: start.dateTime) || null;
|
||||
const soldOut = e.dates?.status?.code === 'offsale' ||
|
||||
e.dates?.status?.code === 'cancelled';
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user