Compare commits
No commits in common. "8a2a9564b837046a25bba0f7b9f7bfb2aefd28ae" and "40c53f431385b19c5a99652b69a63a8984346e2f" have entirely different histories.
8a2a9564b8
...
40c53f4313
3 changed files with 7 additions and 21 deletions
|
@ -14,7 +14,7 @@ val ownerID = 372703841151614976L
|
||||||
group = "net.moonleay.rssbot"
|
group = "net.moonleay.rssbot"
|
||||||
version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" }
|
version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" }
|
||||||
?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" }
|
?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" }
|
||||||
?: "0.3.3"
|
?: "0.3.1"
|
||||||
|
|
||||||
val kordver = "1.5.10-SNAPSHOT"
|
val kordver = "1.5.10-SNAPSHOT"
|
||||||
val coroutinesver = "1.7.3"
|
val coroutinesver = "1.7.3"
|
||||||
|
|
|
@ -29,7 +29,7 @@ import java.time.LocalDateTime
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
|
|
||||||
object MessageUtil {
|
object MessageUtil {
|
||||||
private val dtf: DateTimeFormatter = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss")
|
private val dtf: DateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy @ HH:mm:ss")
|
||||||
|
|
||||||
///Send an embedded message as a reply
|
///Send an embedded message as a reply
|
||||||
suspend fun sendEmbedForPublicSlashCommand(
|
suspend fun sendEmbedForPublicSlashCommand(
|
||||||
|
|
|
@ -20,27 +20,13 @@ package net.moonleay.rssbot.util
|
||||||
|
|
||||||
import java.time.ZonedDateTime
|
import java.time.ZonedDateTime
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
import java.time.format.DateTimeParseException
|
|
||||||
|
|
||||||
|
|
||||||
object TimeUtil {
|
object TimeUtil {
|
||||||
fun getUnixTimeFromStamp(input: String): Long { // Pattern: Sun, 15 Oct 2023 11:04:57 GMT
|
fun getUnixTimeFromStamp(input: String): Long { // Pattern: Sun, 15 Oct 2023 11:04:57 GMT
|
||||||
try {
|
val formatter = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss z")
|
||||||
val formatter = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss zzz")
|
|
||||||
val result = ZonedDateTime.parse(input, formatter).toEpochSecond() * 1000
|
val result = ZonedDateTime.parse(input, formatter).toEpochSecond() * 1000
|
||||||
Logger.out("Converted $input to $result")
|
Logger.out("Converted $input to $result")
|
||||||
return result
|
return result
|
||||||
} catch (e: DateTimeParseException) {
|
|
||||||
Logger.out("Could not convert $input to unix time, trying other pattern")
|
|
||||||
return try {
|
|
||||||
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssX")
|
|
||||||
val result = ZonedDateTime.parse(input, formatter).toEpochSecond() * 1000
|
|
||||||
Logger.out("Converted $input to $result")
|
|
||||||
result
|
|
||||||
} catch (e: DateTimeParseException) {
|
|
||||||
Logger.out("Could not convert $input to unix time")
|
|
||||||
0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // I'm ashamed of this code. I'm sorry. I don't know how to do it better.
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue