game2006go/server/light_backtask/mt/HashRateCommon.go
2024-08-03 14:37:54 +08:00

57 lines
1.1 KiB
Go

package mt
import (
"f5"
"main/mtb"
"time"
)
type HashRateCommon struct {
mtb.HashRateCommon
_start_time int64
_end_time int64
}
type HashRateCommonTable struct {
f5.IdMetaTable[HashRateCommon]
}
func (this *HashRateCommon) Init1() {
dt1, _ := time.Parse("2006-1-02 15:04:05", this.GetStartTime())
this._start_time = dt1.Unix()
dt2, _ := time.Parse("2006-1-02 15:04:05", this.GetEndTime())
this._end_time = dt2.Unix()
}
func (this *HashRateCommonTable) PostInit1() {
}
func (this *HashRateCommonTable) GetLatestPeriod() *HashRateCommon {
var result *HashRateCommon
this.Traverse(
func(meta *HashRateCommon) bool {
if result == nil {
result = meta
return true
}
if f5.GetApp().GetNowSeconds() < meta._start_time {
return false
}
if f5.GetApp().GetNowSeconds() >= meta._end_time {
result = meta
}
return true
})
return result
}
func (this HashRateCommonTable) CheckAwaitTime() bool {
period := this.GetLatestPeriod()
if period != nil && f5.GetApp().GetNowSeconds() > period._end_time {
return true
}
return false
}