File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
library/src/main/java/com/owncloud/android/lib/resources/assistant/chat/model Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change 88package com.owncloud.android.lib.resources.assistant.chat.model
99
1010import com.google.gson.annotations.SerializedName
11+ import java.time.ZoneId
12+ import java.time.format.DateTimeFormatter
13+ import java.util.Locale
14+ import kotlin.time.ExperimentalTime
15+ import kotlin.time.Instant
16+ import kotlin.time.toJavaInstant
1117
1218data class ChatMessage (
1319 val id : Long ,
@@ -21,5 +27,22 @@ data class ChatMessage(
2127 val sources : String ,
2228 val attachments : List <Any ?>
2329) {
24- val isHuman: Boolean = (role == " human" )
30+ companion object {
31+ private const val TIMESTAMP_PRESENTATION_TIME_PATTERN = " HH:mm"
32+ }
33+
34+ fun isHuman (): Boolean {
35+ return role == " human"
36+ }
37+
38+ @OptIn(ExperimentalTime ::class )
39+ fun timestampRepresentation (): String {
40+ val instant = Instant .fromEpochSeconds(timestamp)
41+ val deviceZone = ZoneId .systemDefault()
42+
43+ val formatter = DateTimeFormatter .ofPattern(TIMESTAMP_PRESENTATION_TIME_PATTERN , Locale .getDefault())
44+ .withZone(deviceZone)
45+
46+ return formatter.format(instant.toJavaInstant())
47+ }
2548}
You can’t perform that action at this time.
0 commit comments