2023-08-04 11:13:41 +08:00
|
|
|
package worker
|
|
|
|
|
2023-08-04 18:27:37 +08:00
|
|
|
import (
|
|
|
|
"github.com/go-co-op/gocron"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2023-08-04 20:35:50 +08:00
|
|
|
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
|
|
|
|
}
|
2023-08-04 11:13:41 +08:00
|
|
|
func Init() error {
|
2023-08-04 18:27:37 +08:00
|
|
|
timezone, _ := time.LoadLocation("Asia/Shanghai")
|
|
|
|
cron := gocron.NewScheduler(timezone)
|
2023-08-09 22:00:55 +08:00
|
|
|
cron.Every(1).Minute().Do(func() {
|
2023-08-04 18:27:37 +08:00
|
|
|
go SyncCheckin(time.Now().Format("2006-01-02"))
|
|
|
|
})
|
2023-08-04 18:47:12 +08:00
|
|
|
|
|
|
|
cron.StartAsync()
|
2023-08-04 11:13:41 +08:00
|
|
|
return nil
|
|
|
|
}
|