Skip to content

Commit 17583de

Browse files
committed
Fixed remaining time.Now().Local()
1 parent 5a4c557 commit 17583de

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

cron.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func (c *Cron) run() {
196196

197197
case newEntry := <-c.add:
198198
c.entries = append(c.entries, newEntry)
199-
newEntry.Next = newEntry.Schedule.Next(time.Now().Local())
199+
newEntry.Next = newEntry.Schedule.Next(time.Now().In(c.location))
200200

201201
case <-c.snapshot:
202202
c.snapshot <- c.entrySnapshot()

cron_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ func TestAddWhileRunningWithDelay(t *testing.T) {
116116
defer cron.Stop()
117117
time.Sleep(5 * time.Second)
118118
var calls = 0
119-
cron.AddFunc("* * * * * *", func() { calls += 1 });
119+
cron.AddFunc("* * * * * *", func() { calls += 1 })
120120

121-
<- time.After(ONE_SECOND)
121+
<-time.After(ONE_SECOND)
122122
if calls != 1 {
123123
fmt.Printf("called %d times, expected 1\n", calls)
124124
t.Fail()
@@ -237,7 +237,6 @@ func TestLocalTimezone(t *testing.T) {
237237
}
238238
}
239239

240-
241240
// Test that the cron is run in the given time zone (as opposed to local).
242241
func TestNonLocalTimezone(t *testing.T) {
243242
wg := &sync.WaitGroup{}

0 commit comments

Comments
 (0)