Fix date formatting on Transaction details
Signed-off-by: William Brawner <me@wbrawner.com>
This commit is contained in:
parent
6e32b5f6a3
commit
4a745f57e7
2 changed files with 10 additions and 4 deletions
|
@ -18,12 +18,11 @@ import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.LocalContext
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.wbrawner.budget.ui.TwigsScaffold
|
import com.wbrawner.budget.ui.TwigsScaffold
|
||||||
import com.wbrawner.budget.ui.base.TwigsApp
|
import com.wbrawner.budget.ui.base.TwigsApp
|
||||||
import com.wbrawner.budget.ui.util.format
|
import com.wbrawner.budget.ui.util.formatWithTime
|
||||||
import com.wbrawner.twigs.shared.Action
|
import com.wbrawner.twigs.shared.Action
|
||||||
import com.wbrawner.twigs.shared.Store
|
import com.wbrawner.twigs.shared.Store
|
||||||
import com.wbrawner.twigs.shared.budget.Budget
|
import com.wbrawner.twigs.shared.budget.Budget
|
||||||
|
@ -96,9 +95,13 @@ fun TransactionDetails(
|
||||||
text = transaction.title,
|
text = transaction.title,
|
||||||
style = MaterialTheme.typography.headlineMedium
|
style = MaterialTheme.typography.headlineMedium
|
||||||
)
|
)
|
||||||
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = transaction.date.format(LocalContext.current),
|
text = transaction.date.formatWithTime(),
|
||||||
style = MaterialTheme.typography.bodyMedium
|
style = MaterialTheme.typography.bodyMedium
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
|
|
|
@ -26,6 +26,7 @@ import kotlinx.datetime.TimeZone
|
||||||
import kotlinx.datetime.atStartOfDayIn
|
import kotlinx.datetime.atStartOfDayIn
|
||||||
import kotlinx.datetime.toInstant
|
import kotlinx.datetime.toInstant
|
||||||
import kotlinx.datetime.toLocalDateTime
|
import kotlinx.datetime.toLocalDateTime
|
||||||
|
import java.text.DateFormat.getDateTimeInstance
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -108,3 +109,5 @@ fun Instant.format(context: Context): String =
|
||||||
this.toLocalDateTime(TimeZone.currentSystemDefault()).date.atStartOfDayIn(TimeZone.currentSystemDefault())
|
this.toLocalDateTime(TimeZone.currentSystemDefault()).date.atStartOfDayIn(TimeZone.currentSystemDefault())
|
||||||
.toEpochMilliseconds()
|
.toEpochMilliseconds()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fun Instant.formatWithTime(): String = getDateTimeInstance().format(this.toEpochMilliseconds())
|
||||||
|
|
Loading…
Reference in a new issue