mirror of
https://github.com/DreamExposure/DisCal-Discord-Bot.git
synced 2026-05-12 20:58:30 -05:00
Display day of week in overview, eg Wednesday - 08 December 2021
This commit is contained in:
+1
-1
@@ -55,7 +55,7 @@ object CalendarEmbed : EmbedMaker {
|
||||
// Show events
|
||||
events.forEach { date ->
|
||||
|
||||
val title = date.key.toInstant().humanReadableDate(calendar.timezone, settings.timeFormat, true)
|
||||
val title = date.key.toInstant().humanReadableDate(calendar.timezone, settings.timeFormat, longDay = true)
|
||||
|
||||
// sort events
|
||||
val sortedEvents = date.value.sortedBy { it.start }
|
||||
|
||||
@@ -9,9 +9,9 @@ import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@Serializable(with = TimeFormatAsIntSerializer::class)
|
||||
enum class TimeFormat(val value: Int = 1, val full: String, val date: String, val longDate: String, val time: String) {
|
||||
TWENTY_FOUR_HOUR(1, "LLLL dd yyyy '@' HH:mm", "yyyy/MM/dd", "dd LLLL yyyy", "HH:mm"),
|
||||
TWELVE_HOUR(2, "LLLL dd yyyy '@' hh:mm a", "yyyy/MM/dd", "dd LLLL yyyy", "hh:mm a");
|
||||
enum class TimeFormat(val value: Int = 1, val full: String, val date: String, val longDate: String, val time: String, val dayOfWeek: String) {
|
||||
TWENTY_FOUR_HOUR(1, "LLLL dd yyyy '@' HH:mm", "yyyy/MM/dd", "dd LLLL yyyy", "HH:mm", "EEEE '-' dd LLLL yyyy"),
|
||||
TWELVE_HOUR(2, "LLLL dd yyyy '@' hh:mm a", "yyyy/MM/dd", "dd LLLL yyyy", "hh:mm a", "EEEE '-' dd LLLL yyyy");
|
||||
|
||||
companion object {
|
||||
fun isValid(i: Int): Boolean {
|
||||
|
||||
@@ -12,8 +12,9 @@ fun Instant.humanReadableFull(timezone: ZoneId, format: TimeFormat): String {
|
||||
return DateTimeFormatter.ofPattern(format.full).withZone(timezone).format(this)
|
||||
}
|
||||
|
||||
fun Instant.humanReadableDate(timezone: ZoneId, format: TimeFormat, long: Boolean): String {
|
||||
return if (long) DateTimeFormatter.ofPattern(format.longDate).withZone(timezone).format(this)
|
||||
fun Instant.humanReadableDate(timezone: ZoneId, format: TimeFormat, long: Boolean = true, longDay: Boolean = false): String {
|
||||
return if (long && longDay) DateTimeFormatter.ofPattern(format.dayOfWeek).withZone(timezone).format(this)
|
||||
else if (long) DateTimeFormatter.ofPattern(format.longDate).withZone(timezone).format(this)
|
||||
else DateTimeFormatter.ofPattern(format.date).withZone(timezone).format(this)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user