@@ -18,6 +18,11 @@ import io.vertx.sqlclient.Row
1818import io.vertx.sqlclient.RowSet
1919import io.vertx.sqlclient.Tuple
2020import kotlinx.coroutines.Dispatchers
21+ import kotlinx.datetime.TimeZone
22+ import kotlinx.datetime.UtcOffset
23+ import kotlinx.datetime.format.DateTimeComponents
24+ import kotlinx.datetime.format.format
25+ import kotlinx.datetime.toLocalDateTime
2126import kotlinx.html.*
2227import kotlinx.html.stream.appendHTML
2328import kotlinx.io.buffered
@@ -26,8 +31,7 @@ import kotlinx.serialization.Serializable
2631import kotlinx.serialization.SerializationStrategy
2732import kotlinx.serialization.json.Json
2833import kotlinx.serialization.json.io.encodeToSink
29- import java.time.ZonedDateTime
30- import java.time.format.DateTimeFormatter
34+ import kotlin.time.Clock
3135
3236class MainVerticle (val hasDb : Boolean ) : CoroutineVerticle(), CoroutineRouterSupport {
3337 // `PgConnection`s as used in the "vertx" portion offers better performance than `PgPool`s.
@@ -40,9 +44,10 @@ class MainVerticle(val hasDb: Boolean) : CoroutineVerticle(), CoroutineRouterSup
4044 lateinit var updateWordQuery: PreparedQuery <RowSet <Row >>
4145
4246 fun setCurrentDate () {
43- // Don't know how to get kotlinx-datetime to work here properly. See commit 9cf28f15b6f1806b3ed75260adee8acd822cac91 for a failed attempt.
44- // date = Clock.System.now().toString()
45- date = DateTimeFormatter .RFC_1123_DATE_TIME .format(ZonedDateTime .now())
47+ date = DateTimeComponents .Formats .RFC_1123 .format {
48+ // We don't need a more complicated system `TimeZone` here (whose offset depends dynamically on the actual time due to DST) since UTC works.
49+ setDateTimeOffset(Clock .System .now(), UtcOffset .ZERO )
50+ }
4651 }
4752
4853 override suspend fun start () {
0 commit comments