diff --git a/app/pom.xml b/app/pom.xml
index 2fffd25..698eb7f 100644
--- a/app/pom.xml
+++ b/app/pom.xml
@@ -52,6 +52,11 @@
org.jetbrains.kotlinx
kotlinx-serialization-runtime
+
+ org.ocpsoft.prettytime
+ prettytime
+ 4.0.5.Final
+
be.simplenotes
@@ -119,6 +124,12 @@
**
+
+ org.ocpsoft.prettytime:prettytime
+
+ **
+
+
*:*
diff --git a/app/src/main/kotlin/utils/PrettyDate.kt b/app/src/main/kotlin/utils/PrettyDate.kt
new file mode 100644
index 0000000..9294e9a
--- /dev/null
+++ b/app/src/main/kotlin/utils/PrettyDate.kt
@@ -0,0 +1,10 @@
+package be.simplenotes.app.utils
+
+import org.ocpsoft.prettytime.PrettyTime
+import java.time.LocalDateTime
+import java.time.ZoneId
+import java.util.*
+
+private val prettyTime = PrettyTime()
+
+fun LocalDateTime.toTimeAgo(): String = prettyTime.format(Date.from(atZone(ZoneId.systemDefault()).toInstant()))
diff --git a/app/src/main/kotlin/views/components/DeletedNoteTable.kt b/app/src/main/kotlin/views/components/DeletedNoteTable.kt
index be9300e..0be5135 100644
--- a/app/src/main/kotlin/views/components/DeletedNoteTable.kt
+++ b/app/src/main/kotlin/views/components/DeletedNoteTable.kt
@@ -1,11 +1,11 @@
package be.simplenotes.app.views.components
+import be.simplenotes.app.utils.toTimeAgo
import be.simplenotes.domain.model.PersistedNoteMetadata
import kotlinx.html.*
import kotlinx.html.ButtonType.submit
import kotlinx.html.FormMethod.post
import kotlinx.html.ThScope.col
-import org.http4k.core.Method
fun FlowContent.deletedNoteTable(notes: List) = div("overflow-x-auto") {
table {
@@ -22,7 +22,7 @@ fun FlowContent.deletedNoteTable(notes: List) = div("over
notes.forEach { (title, tags, updatedAt, uuid) ->
tr {
td { +title }
- td("text-center") { +updatedAt.toString() } // TODO: x time ago
+ td("text-center") { +updatedAt.toTimeAgo() }
td { tags(tags) }
td("text-center") {
form(classes = "inline", method = post, action = "/notes/deleted/$uuid") {
diff --git a/app/src/main/kotlin/views/components/NoteTable.kt b/app/src/main/kotlin/views/components/NoteTable.kt
index 32ff42e..3133365 100644
--- a/app/src/main/kotlin/views/components/NoteTable.kt
+++ b/app/src/main/kotlin/views/components/NoteTable.kt
@@ -1,5 +1,6 @@
package be.simplenotes.app.views.components
+import be.simplenotes.app.utils.toTimeAgo
import be.simplenotes.domain.model.PersistedNoteMetadata
import kotlinx.html.*
import kotlinx.html.ThScope.col
@@ -20,7 +21,9 @@ fun FlowContent.noteTable(notes: List) = div("overflow-x-
td {
a(classes = "text-blue-200 font-semibold underline", href = "/notes/$uuid") { +title }
}
- td("text-center") { +updatedAt.toString() } // TODO: x time ago
+ td("text-center") {
+ +updatedAt.toTimeAgo()
+ }
td { tags(tags) }
}
}