operator.go 768 B

123456789101112131415161718192021222324252627282930313233
  1. package operator
  2. import (
  3. "time"
  4. "go-common/library/log"
  5. xtime "go-common/library/time"
  6. )
  7. type Reddot struct {
  8. StartTime xtime.Time `json:"start_time,omitempty"`
  9. EndTime xtime.Time `json:"end_time,omitempty"`
  10. }
  11. // ReddotChange Reddot change
  12. func (r *Reddot) ReddotChange(startStr, endStr string) {
  13. if startStr != "" && endStr != "" {
  14. r.StartTime = timeStrToInt(startStr)
  15. r.EndTime = timeStrToInt(endStr)
  16. }
  17. }
  18. // timeStrToInt string to int
  19. func timeStrToInt(timeStr string) (timeInt xtime.Time) {
  20. var err error
  21. timeLayout := "2006-01-02 15:04:05"
  22. loc, _ := time.LoadLocation("Local")
  23. theTime, _ := time.ParseInLocation(timeLayout, timeStr, loc)
  24. if err = timeInt.Scan(theTime); err != nil {
  25. log.Error("timeInt.Scan error(%v)", err)
  26. }
  27. return
  28. }