Skip to content

Commit f37367d

Browse files
committed
implement chat content
Signed-off-by: alperozturk <[email protected]>
1 parent fb912c3 commit f37367d

File tree

1 file changed

+24
-1
lines changed
  • library/src/main/java/com/owncloud/android/lib/resources/assistant/chat/model

1 file changed

+24
-1
lines changed

library/src/main/java/com/owncloud/android/lib/resources/assistant/chat/model/ChatMessage.kt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
package com.owncloud.android.lib.resources.assistant.chat.model
99

1010
import 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

1218
data 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
}

0 commit comments

Comments
 (0)