From 17583deb80cd395a43ea18131d688672680a4370 Mon Sep 17 00:00:00 2001 From: Wannes Date: Fri, 12 Aug 2016 12:13:02 +0200 Subject: [PATCH] Fixed remaining time.Now().Local() --- cron.go | 2 +- cron_test.go | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cron.go b/cron.go index 137a2f98..f648e6de 100644 --- a/cron.go +++ b/cron.go @@ -196,7 +196,7 @@ func (c *Cron) run() { case newEntry := <-c.add: c.entries = append(c.entries, newEntry) - newEntry.Next = newEntry.Schedule.Next(time.Now().Local()) + newEntry.Next = newEntry.Schedule.Next(time.Now().In(c.location)) case <-c.snapshot: c.snapshot <- c.entrySnapshot() diff --git a/cron_test.go b/cron_test.go index 8f603ab1..96f62b9d 100644 --- a/cron_test.go +++ b/cron_test.go @@ -116,9 +116,9 @@ func TestAddWhileRunningWithDelay(t *testing.T) { defer cron.Stop() time.Sleep(5 * time.Second) var calls = 0 - cron.AddFunc("* * * * * *", func() { calls += 1 }); + cron.AddFunc("* * * * * *", func() { calls += 1 }) - <- time.After(ONE_SECOND) + <-time.After(ONE_SECOND) if calls != 1 { fmt.Printf("called %d times, expected 1\n", calls) t.Fail() @@ -237,7 +237,6 @@ func TestLocalTimezone(t *testing.T) { } } - // Test that the cron is run in the given time zone (as opposed to local). func TestNonLocalTimezone(t *testing.T) { wg := &sync.WaitGroup{}