mirror of
https://github.com/grimsi/gameyfin.git
synced 2026-02-06 11:27:07 +00:00
Fix parsing of "Coming soon" in date field
This commit is contained in:
parent
99ff18bac6
commit
355cfcbe65
@ -16,6 +16,9 @@ import java.util.*
|
||||
class SteamDateSerializer : KSerializer<Instant> {
|
||||
|
||||
companion object {
|
||||
const val COMING_SOON_TEXT = "Coming Soon"
|
||||
val COMING_SOON_FALLBACK_DATE: LocalDate = LocalDate.parse("2999-12-31")
|
||||
|
||||
val formatter: DateTimeFormatter = DateTimeFormatter.ofPattern("d MMM, yyyy", Locale.ENGLISH)
|
||||
}
|
||||
|
||||
@ -24,6 +27,10 @@ class SteamDateSerializer : KSerializer<Instant> {
|
||||
override fun serialize(encoder: Encoder, value: Instant) = encoder.encodeString(value.toString())
|
||||
|
||||
private fun fromString(dateString: String): Instant {
|
||||
if (dateString.equals(COMING_SOON_TEXT, true)) {
|
||||
return COMING_SOON_FALLBACK_DATE.atStartOfDay().toInstant(ZoneOffset.UTC)
|
||||
}
|
||||
|
||||
val localDate = LocalDate.parse(dateString, formatter)
|
||||
return localDate.atStartOfDay().toInstant(ZoneOffset.UTC)
|
||||
}
|
||||
|
||||
@ -2,5 +2,5 @@ Manifest-Version: 1.0
|
||||
Plugin-Class: de.grimsi.gameyfin.plugins.steam.SteamPlugin
|
||||
Plugin-Id: steam
|
||||
Plugin-Description: Steam Metadata
|
||||
Plugin-Version: 1.0.0-alpha5
|
||||
Plugin-Version: 1.0.0-alpha6
|
||||
Plugin-Provider: grimsi
|
||||
|
||||
Loading…
Reference in New Issue
Block a user