26 lines
447 B
Go
26 lines
447 B
Go
package worker
|
|
|
|
import (
|
|
"github.com/go-co-op/gocron"
|
|
"time"
|
|
)
|
|
|
|
func Init1() error {
|
|
|
|
for i := 0; i < 120; i++ {
|
|
day := time.Now().AddDate(0, 0, -1-i).Format("2006-01-02")
|
|
SyncCheckin(day)
|
|
}
|
|
return nil
|
|
}
|
|
func Init() error {
|
|
timezone, _ := time.LoadLocation("Asia/Shanghai")
|
|
cron := gocron.NewScheduler(timezone)
|
|
cron.Every(1).Minute().Do(func() {
|
|
go SyncCheckin(time.Now().Format("2006-01-02"))
|
|
})
|
|
|
|
cron.StartAsync()
|
|
return nil
|
|
}
|