use compose-observable locale in DayHeader
This commit is contained in:
parent
cf82b4b586
commit
b21c4d0f46
1 changed files with 3 additions and 3 deletions
|
|
@ -44,7 +44,6 @@ import space.darkest.nova.android.data.AgendaEvent
|
|||
import java.time.LocalDate
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.format.TextStyle
|
||||
import java.util.Locale
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
|
|
@ -114,13 +113,14 @@ fun AgendaScreen(agenda: List<AgendaDay>) {
|
|||
|
||||
@Composable
|
||||
private fun DayHeader(date: LocalDate) {
|
||||
val locale = androidx.compose.ui.text.intl.Locale.current.platformLocale
|
||||
val today = LocalDate.now()
|
||||
val label = when (date) {
|
||||
today -> "Today"
|
||||
today.plusDays(1) -> "Tomorrow"
|
||||
else -> {
|
||||
val dayName = date.dayOfWeek.getDisplayName(TextStyle.FULL, Locale.getDefault())
|
||||
val monthDay = date.format(DateTimeFormatter.ofPattern("MMM d"))
|
||||
val dayName = date.dayOfWeek.getDisplayName(TextStyle.FULL, locale)
|
||||
val monthDay = date.format(DateTimeFormatter.ofPattern("MMM d", locale))
|
||||
"$dayName, $monthDay"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue