Let's not throw a time zone exception, shall we?
authorTheSaminator <TheSaminator@users.noreply.github.com>
Mon, 7 Feb 2022 17:10:06 +0000 (12:10 -0500)
committerTheSaminator <TheSaminator@users.noreply.github.com>
Mon, 7 Feb 2022 17:10:06 +0000 (12:10 -0500)
src/jvmMain/kotlin/starshipfights/info/views_user.kt
src/jvmMain/resources/static/init.js

index 015a5c364be54a52e38a8db8c233f3c75f0dfe5f..2d0be5faf1bce97fb0a8042879e331cf0b5ccf2f 100644 (file)
@@ -24,11 +24,6 @@ import starshipfights.game.GlobalSide
 import starshipfights.game.toUrlSlug
 import starshipfights.redirect
 import java.time.Instant
-import java.time.format.DateTimeFormatter
-import java.time.format.FormatStyle
-import java.util.*
-
-private val instantFormatter: DateTimeFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(Locale.US)
 
 suspend fun ApplicationCall.userPage(): HTML.() -> Unit {
        val username = parameters["name"]!!
@@ -169,7 +164,10 @@ suspend fun ApplicationCall.manageUserPage(): HTML.() -> Unit {
                                                }
                                                td {
                                                        +"Expired at "
-                                                       +instantFormatter.format(Instant.ofEpochMilli(session.expirationMillis))
+                                                       span(classes = "moment") {
+                                                               style = "display:none"
+                                                               +session.expirationMillis.toString()
+                                                       }
                                                }
                                        }
                                }
@@ -365,7 +363,10 @@ suspend fun ApplicationCall.admiralPage(): HTML.() -> Unit {
                                                                }
                                                }
                                                td {
-                                                       +instantFormatter.format(record.whenEnded)
+                                                       span(classes = "moment") {
+                                                               style = "display:none"
+                                                               +record.whenEnded.toEpochMilli().toString()
+                                                       }
                                                }
                                                td {
                                                        +when (recordRoles[record.id]) {
index 57b7818cd8aeed66c64288886ac59d7df69fc0b5..3ea86f80ced2c5a9956ac3283a4120c3a0f64bd2 100644 (file)
@@ -63,3 +63,12 @@ window.addEventListener("load", function () {
                });
        }
 });
+
+window.addEventListener("load", function () {
+       const moments = document.getElementsByClassName("moment");
+       for (let moment of moments) {
+               let date = new Date(Number(moment.innerHTML.trim()));
+               moment.innerHTML = date.toLocaleString();
+               moment.attributes["style"] = "";
+       }
+});