Format time
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package ac.aux.compose.extensions
|
||||
|
||||
import kotlinx.datetime.LocalDateTime
|
||||
import kotlinx.datetime.TimeZone
|
||||
import kotlinx.datetime.format
|
||||
import kotlinx.datetime.format.char
|
||||
import kotlinx.datetime.toLocalDateTime
|
||||
import kotlin.time.Instant
|
||||
|
||||
fun Instant.toFormattedTimeAndDateString(): String {
|
||||
return toLocalDateTime(TimeZone.currentSystemDefault()).format(
|
||||
LocalDateTime.Format {
|
||||
year()
|
||||
char('-')
|
||||
monthNumber()
|
||||
char('-')
|
||||
day()
|
||||
char(' ')
|
||||
hour()
|
||||
char(':')
|
||||
minute()
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package ac.aux.compose.ui.composable.widgets.feed
|
||||
|
||||
import ac.aux.compose.database.model.NostrEvent
|
||||
import ac.aux.compose.extensions.toFormattedTimeAndDateString
|
||||
import ac.aux.compose.ui.theme.AuxTheme
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -88,7 +89,7 @@ fun NostrEvent.ListView() {
|
||||
}
|
||||
|
||||
Text(
|
||||
text = createdAt.toString()
|
||||
text = createdAt.toFormattedTimeAndDateString()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user