File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "fmt"
5+ "time"
6+
7+ "github.com/gitploy-io/cronexpr"
8+ )
9+
10+ func main () {
11+ nextTime := cronexpr .MustParseInLocation ("0 * * * *" , "Asia/Seoul" ).Next (time .Now ())
12+ fmt .Printf ("Parse the cron expression in the KR timezone: %s" , nextTime )
13+ }
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ func (s *Schedule) Next(t time.Time) time.Time {
1818 loc = s .Location
1919 }
2020
21+ origLoc := t .Location ()
2122 t .In (loc )
2223
2324 added := false
9293 }
9394 }
9495
95- return t
96+ return t . In ( origLoc )
9697}
9798
9899func (s * Schedule ) Prev (t time.Time ) time.Time {
@@ -101,6 +102,7 @@ func (s *Schedule) Prev(t time.Time) time.Time {
101102 loc = s .Location
102103 }
103104
105+ origLoc := t .Location ()
104106 t .In (loc )
105107
106108 subtracted := false
176178 }
177179 }
178180
179- return t
181+ return t . In ( origLoc )
180182}
181183
182184// dayMatches returns true if the schedule's day-of-week and day-of-month
You can’t perform that action at this time.
0 commit comments