All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xyz.cssxsh.mirai.bilibili.data.BiliInterval.kt Maven / Gradle / Ivy

The newest version!
package xyz.cssxsh.mirai.bilibili.data

import kotlinx.serialization.*
import xyz.cssxsh.mirai.bilibili.*
import java.time.*

@Serializable
class BiliInterval(
    @SerialName("start")
    @Serializable(with = LocalTimeSerializer::class)
    override val start: LocalTime,
    @SerialName("end")
    @Serializable(with = LocalTimeSerializer::class)
    override val endInclusive: LocalTime
) : ClosedRange {
    override fun contains(value: LocalTime): Boolean {
        return when {
            start < endInclusive -> value >= start && value <= endInclusive
            start > endInclusive -> value >= start || value <= endInclusive
            else -> false
        }
    }

    override fun isEmpty(): Boolean = (start == endInclusive)

    override fun toString(): String = "$start~$endInclusive"
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy