MCPcopy Index your code
hub / github.com/coder/coder / Min

Method Min

coderd/schedule/cron/cron.go:212–228  ·  view source on GitHub ↗

Min returns the minimum duration of the schedule. This is calculated as follows: - Let t(0) be a given point in time (1970-01-01T01:01:01Z00:00) - Let t(max) be 168 hours after t(0). - Let t(1) be the next scheduled time after t(0). - Let t(n) be the next scheduled time after t(n-1). - Then, the min

()

Source from the content-addressed store, hash-verified

210// - Then, the minimum duration of s d(min)
211// = min( t(n) - t(n-1) ∀ n ∈ N, t(n) < t(max) )
212func (s Schedule) Min() time.Duration {
213 durMin := tMax.Sub(t0)
214 tPrev := s.Next(t0)
215 tCurr := s.Next(tPrev)
216 for {
217 dur := tCurr.Sub(tPrev)
218 if dur < durMin {
219 durMin = dur
220 }
221 tPrev = tCurr
222 tCurr = s.Next(tCurr)
223 if tCurr.After(tMax) {
224 break
225 }
226 }
227 return durMin
228}
229
230// TimeParsed returns the parsed time.Time of the minute and hour fields. If the
231// time cannot be represented in a valid time.Time, a zero time is returned.

Callers 3

Test_WeeklyFunction · 0.80
scaleDesktopCoordinateFunction · 0.80
ConvertStateFunction · 0.80

Calls 1

NextMethod · 0.95

Tested by 1

Test_WeeklyFunction · 0.64