mirror of
https://github.com/DreamExposure/DisCal-Discord-Bot.git
synced 2026-05-06 09:10:09 -05:00
This should fix all the formatting issues
This commit is contained in:
+9
-6
@@ -53,12 +53,15 @@ object CalendarEmbed : EmbedMaker {
|
||||
|
||||
// Show events
|
||||
events.forEach { date ->
|
||||
val fieldTitle = date.key.toInstant().humanReadableDate(calendar.timezone, settings.timeFormat)
|
||||
|
||||
val content = StringBuilder()
|
||||
date.value.forEach {
|
||||
content.append("```\n")
|
||||
.append(it.start.humanReadableTime(it.timezone, settings.timeFormat))
|
||||
val title = date.key.toInstant().humanReadableDate(calendar.timezone, settings.timeFormat, true)
|
||||
|
||||
// sort events
|
||||
val sortedEvents = date.value.sortedBy { it.start }
|
||||
|
||||
val content = StringBuilder().append("```\n")
|
||||
sortedEvents.forEach {
|
||||
content.append(it.start.humanReadableTime(it.timezone, settings.timeFormat))
|
||||
.append(" - ")
|
||||
.append(it.end.humanReadableTime(it.timezone, settings.timeFormat))
|
||||
.append(" | ")
|
||||
@@ -68,7 +71,7 @@ object CalendarEmbed : EmbedMaker {
|
||||
}
|
||||
content.append("```")
|
||||
|
||||
builder.addField(fieldTitle, content.toString(), false)
|
||||
builder.addField(title, content.toString(), false)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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 time: String) {
|
||||
TWENTY_FOUR_HOUR(1, "LLLL dd yyyy '@' HH:mm", "yyyy/MM/dd", "HH:mm"),
|
||||
TWELVE_HOUR(2, "LLLL dd yyyy '@' hh:mm a", "yyyy/MM/dd hh:mm a", "hh:mm a");
|
||||
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");
|
||||
|
||||
companion object {
|
||||
fun isValid(i: Int): Boolean {
|
||||
|
||||
@@ -11,8 +11,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): String {
|
||||
return DateTimeFormatter.ofPattern(format.date).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)
|
||||
else DateTimeFormatter.ofPattern(format.date).withZone(timezone).format(this)
|
||||
}
|
||||
|
||||
fun Instant.humanReadableTime(timezone: ZoneId, format: TimeFormat): String {
|
||||
|
||||
Reference in New Issue
Block a user