summaryrefslogtreecommitdiffstats
path: root/modules/cron/constantdelay.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-02-20 15:58:09 -0500
committerUnknwon <u@gogs.io>2016-02-20 15:58:09 -0500
commitd8a994ef243349f321568f9e36d5c3f444b99cae (patch)
tree09cab4dc4c1f585b91a40c594e9e0f7b8967944d /modules/cron/constantdelay.go
parent7140dbac95a96849a7f82166439fd72a7b56f9bf (diff)
downloadgitea-d8a994ef243349f321568f9e36d5c3f444b99cae.tar.gz
gitea-d8a994ef243349f321568f9e36d5c3f444b99cae.zip
Move cron module to independent package
Make it easier to keep track of upstream changes and bug fixes
Diffstat (limited to 'modules/cron/constantdelay.go')
-rw-r--r--modules/cron/constantdelay.go27
1 files changed, 0 insertions, 27 deletions
diff --git a/modules/cron/constantdelay.go b/modules/cron/constantdelay.go
deleted file mode 100644
index cd6e7b1be9..0000000000
--- a/modules/cron/constantdelay.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package cron
-
-import "time"
-
-// ConstantDelaySchedule represents a simple recurring duty cycle, e.g. "Every 5 minutes".
-// It does not support jobs more frequent than once a second.
-type ConstantDelaySchedule struct {
- Delay time.Duration
-}
-
-// Every returns a crontab Schedule that activates once every duration.
-// Delays of less than a second are not supported (will round up to 1 second).
-// Any fields less than a Second are truncated.
-func Every(duration time.Duration) ConstantDelaySchedule {
- if duration < time.Second {
- duration = time.Second
- }
- return ConstantDelaySchedule{
- Delay: duration - time.Duration(duration.Nanoseconds())%time.Second,
- }
-}
-
-// Next returns the next time this should be run.
-// This rounds so that the next activation time will be on the second.
-func (schedule ConstantDelaySchedule) Next(t time.Time) time.Time {
- return t.Add(schedule.Delay - time.Duration(t.Nanosecond())*time.Nanosecond)
-}