编辑代码

package main
import (
"fmt"
"time"
"strings"
)
const (
	YYYYMMDDHHMMSSMill = "2006-01-02 15:04:05.000" //年月日 时分秒,毫秒
	YMDHMSMill         = "20060102150405000"
	YYYYMMDDHHMMSS     = "2006-01-02 15:04:05" //年月日 时分秒
	YYYYMMDDHHMM       = "2006-01-02 15:04"    //年月日 时分
	YYYYMMDD           = "2006-01-02"          //年月日
	YMDHMS             = "20060102150405"      //精简版 年月日时分秒
	YMDHM              = "200601021504"        //精简版 年月日时分
	YMD                = "20060102"            //精简版 年月日
	HHMMSS             = "15:04:05"            //时分秒
	HMS                = "150405"              //时分秒
)
func main () {
		// var beginTime int64 =1694499105

		// var endTime int64 = 1694669085
       
        beginTime, err := ParserLocalTime64("2023-09-12 00:23:35")
        if err != nil {
			fmt.Println("b错误")
		}

		endTime, err := ParserLocalTime64("2023-09-14 01:23:35")
		if err != nil {
		 	fmt.Println("e错误")
		}
		beginTime = FixZoneZeroClock(beginTime, 28800)
		endTime = FixZoneZeroClock(endTime, 28800)
		categorys := strings.Split("fanstatus", ",")
		for i := beginTime; i <= endTime; i += 86400 {
             t:=time.Unix(i, 0)
		 	day := t.Format("2006-01-02")
		 	for _, _ = range categorys {
		 		fmt.Println(day)
		 	}
		}



}
func ParserLocalTime64(stime string, fmt ...string) (t int64, err error) {
	var tm time.Time
	if len(fmt) > 0 {
		tm, err = time.ParseInLocation(fmt[0], stime, time.Local)
	} else {
		tm, err = time.ParseInLocation(YYYYMMDDHHMMSS, stime, time.Local)
	}
	if err != nil {
		return
	}
	t = tm.Unix()
	return
}
func FixZoneZeroClock(now, offset int64) int64 {
	now = now + offset //加上8小时,取余,不要跑到昨天
	now -= now % 86400 //8点钟
	now -= offset      //减去时区(8小时)误差
	return now
}