package main
import (
"bufio"
"fmt"
"log"
"os"
"time"
)
func main() {
//开始时间
t1 := time.Date(2020, 3, 1, 0, 0, 0, 0, time.Local)
//结束时间
t2 := time.Date(2021, 10, 4, 0, 0, 0, 0, time.Local)
//不是这个方法
// fmt.Println(t1.Second(), t2.Second())
fmt.Println(t1.Unix(), t2.Unix())
//从上述时间均匀产生
t1_unix := t1.Unix()
t2_unix := t2.Unix()
//
step := (t2_unix - t1_unix) * 1.0 / 1e6
fmt.Println(step)
//
nctimes := make([]int64, 0, 1e6)
//
var i int64
for i = 0; i < 1e6+860; i++ {
nctimes = append(nctimes, i*step+t1_unix)
}
//
f, err := os.Create("nctime.csv")
if err != nil {
log.Fatalln(err)
}
bufioWriter := bufio.NewWriter(f)
//转换时间格式
for _, t := range nctimes {
tt := time.Unix(t, 0)
// fmt.Printf("%c", '.')
// fmt.Println(tt)
// fmt.Println(tt.Format("2006-01-02 15:04:05"))
bufioWriter.WriteString(tt.Format(`'2006-01-02 15:04:05'`) + "\r\n")
// break
}
//
bufioWriter.Flush()
}