go-common/app/interface/main/app-wall/model/operator/operator.go

34 lines
768 B
Go
Raw Normal View History

2019-04-22 10:49:16 +00:00
package operator
import (
"time"
"go-common/library/log"
xtime "go-common/library/time"
)
type Reddot struct {
StartTime xtime.Time `json:"start_time,omitempty"`
EndTime xtime.Time `json:"end_time,omitempty"`
}
// ReddotChange Reddot change
func (r *Reddot) ReddotChange(startStr, endStr string) {
if startStr != "" && endStr != "" {
r.StartTime = timeStrToInt(startStr)
r.EndTime = timeStrToInt(endStr)
}
}
// timeStrToInt string to int
func timeStrToInt(timeStr string) (timeInt xtime.Time) {
var err error
timeLayout := "2006-01-02 15:04:05"
loc, _ := time.LoadLocation("Local")
theTime, _ := time.ParseInLocation(timeLayout, timeStr, loc)
if err = timeInt.Scan(theTime); err != nil {
log.Error("timeInt.Scan error(%v)", err)
}
return
}