commit 09/02/2026
This commit is contained in:
37
src/database/data/QueueTable.kt
Normal file
37
src/database/data/QueueTable.kt
Normal file
@@ -0,0 +1,37 @@
|
||||
package database.data
|
||||
|
||||
import codes.Somecodes.Companion.datetimeformat1
|
||||
import java.time.Duration
|
||||
import java.time.LocalDateTime
|
||||
|
||||
data class QueueTable(var index: UInt, var Date_Time: String, var Source: String, var Type: String, var Message: String, var SB_TAGS: String, var BroadcastZones: String, var Repeat: UInt, 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user