@@ -14,8 +14,8 @@ import io.vertx.kotlin.coroutines.CoroutineVerticle
1414import io.vertx.kotlin.coroutines.coAwait
1515import kotlinx.coroutines.Dispatchers
1616import kotlinx.datetime.UtcOffset
17- import kotlinx.datetime.format.DateTimeComponents
18- import kotlinx.datetime.format.format
17+ import kotlinx.datetime.format.*
18+ import kotlinx.datetime.format.DateTimeComponents.Companion.Format
1919import kotlinx.io.buffered
2020import kotlinx.serialization.ExperimentalSerializationApi
2121import kotlinx.serialization.Serializable
@@ -37,8 +37,41 @@ abstract class CommonVerticle : CoroutineVerticle(), CoroutineRouterSupport {
3737 lateinit var date: String
3838 val random = Random (0 )
3939
40+ object DateTimeComponentsFormats {
41+ // adapted from `DateTimeComponents.Formats.RFC_1123` with seconds made compulsory
42+ val RFC_1123_WITH_COMPULSORY_SECONDS = Format {
43+ alternativeParsing({
44+ // the day of week may be missing
45+ }) {
46+ dayOfWeek(DayOfWeekNames .ENGLISH_ABBREVIATED )
47+ chars(" , " )
48+ }
49+ day(Padding .NONE )
50+ char(' ' )
51+ monthName(MonthNames .ENGLISH_ABBREVIATED )
52+ char(' ' )
53+ year()
54+ char(' ' )
55+ hour()
56+ char(' :' )
57+ minute()
58+ char(' :' )
59+ second()
60+ chars(" " )
61+ alternativeParsing({
62+ chars(" UT" )
63+ }, {
64+ chars(" Z" )
65+ }) {
66+ optional(" GMT" ) {
67+ offset(UtcOffset .Formats .FOUR_DIGITS )
68+ }
69+ }
70+ }
71+ }
72+
4073 fun setCurrentDate () {
41- date = DateTimeComponents . Formats . RFC_1123 .format {
74+ date = DateTimeComponentsFormats . RFC_1123_WITH_COMPULSORY_SECONDS .format {
4275 // We don't need a more complicated system `TimeZone` here (whose offset depends dynamically on the actual time due to DST) since UTC works.
4376 setDateTimeOffset(Clock .System .now(), UtcOffset .ZERO )
4477 }
0 commit comments