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.LocalDate
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
import java.time.format.TextStyle
|
import java.time.format.TextStyle
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -114,13 +113,14 @@ fun AgendaScreen(agenda: List<AgendaDay>) {
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun DayHeader(date: LocalDate) {
|
private fun DayHeader(date: LocalDate) {
|
||||||
|
val locale = androidx.compose.ui.text.intl.Locale.current.platformLocale
|
||||||
val today = LocalDate.now()
|
val today = LocalDate.now()
|
||||||
val label = when (date) {
|
val label = when (date) {
|
||||||
today -> "Today"
|
today -> "Today"
|
||||||
today.plusDays(1) -> "Tomorrow"
|
today.plusDays(1) -> "Tomorrow"
|
||||||
else -> {
|
else -> {
|
||||||
val dayName = date.dayOfWeek.getDisplayName(TextStyle.FULL, Locale.getDefault())
|
val dayName = date.dayOfWeek.getDisplayName(TextStyle.FULL, locale)
|
||||||
val monthDay = date.format(DateTimeFormatter.ofPattern("MMM d"))
|
val monthDay = date.format(DateTimeFormatter.ofPattern("MMM d", locale))
|
||||||
"$dayName, $monthDay"
|
"$dayName, $monthDay"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue