38 lines
1.5 KiB
Kotlin
38 lines
1.5 KiB
Kotlin
package database.data
|
|
|
|
import codes.Somecodes.Companion.datetimeformat1
|
|
import java.time.Duration
|
|
import java.time.LocalDateTime
|
|
|
|
data class QueueTable(var index: UInt=0u, var Date_Time: String =LocalDateTime.now().format(datetimeformat1), var Source: String, var Type: String, var Message: String, var SB_TAGS: String, var BroadcastZones: String, var Repeat: UInt=1u, var Language: String){
|
|
|
|
/**
|
|
* Check if all fields are not empty
|
|
*/
|
|
fun isNotEmpty(): Boolean {
|
|
return Date_Time.isNotEmpty() && Source.isNotEmpty() && Type.isNotEmpty() && Message.isNotEmpty() && SB_TAGS.isNotEmpty() && BroadcastZones.isNotEmpty() && Language.isNotEmpty()
|
|
}
|
|
override fun toString(): String {
|
|
return "QueueTable(index=$index, Date_Time='$Date_Time', Source='$Source', Type='$Type', Message='$Message', SB_TAGS='$SB_TAGS', BroadcastZones='$BroadcastZones', Repeat=$Repeat, Language='$Language')"
|
|
}
|
|
|
|
companion object{
|
|
|
|
/**
|
|
* Check if the QueueTable entry is expired (older than 5 seconds)
|
|
* @param qt QueueTable entry to check
|
|
* @return true if expired, false otherwise
|
|
*/
|
|
fun isExpired(qt: QueueTable) : Boolean{
|
|
try{
|
|
val t1 = LocalDateTime.parse(qt.Date_Time, datetimeformat1)
|
|
val delta = Duration.between(t1, LocalDateTime.now())
|
|
// expired if more than 5 seconds
|
|
return delta.seconds > 5
|
|
} catch (_: Exception){
|
|
return false
|
|
}
|
|
}
|
|
}
|
|
}
|