add cron timezone
This commit is contained in:
@@ -2,6 +2,8 @@ package cronhu
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/robfig/cron/v3"
|
||||
"go.uber.org/dig"
|
||||
@@ -9,8 +11,13 @@ import (
|
||||
|
||||
func Init(di *dig.Container) *cron.Cron {
|
||||
|
||||
c := cron.New()
|
||||
err := di.Provide(func() *cron.Cron {
|
||||
location, err := time.LoadLocation(os.Getenv("TIMEZONE"))
|
||||
|
||||
if err != nil {
|
||||
log.Panic("unable to load timezone!")
|
||||
}
|
||||
c := cron.New(cron.WithLocation(location))
|
||||
err = di.Provide(func() *cron.Cron {
|
||||
return c
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user