MCPcopy Create free account
hub / github.com/codnect/chrono / nextField

Method nextField

cron.go:126–152  ·  view source on GitHub ↗
(field *cronFieldBits, t time.Time)

Source from the content-addressed store, hash-verified

124}
125
126func (expression *CronExpression) nextField(field *cronFieldBits, t time.Time) time.Time {
127 current := getTimeValue(t, field.Typ.Field)
128 next := setNextBit(field.Bits, current)
129
130 if next == -1 {
131 amount := getFieldMaxValue(t, field.Typ) - current + 1
132 t = addTime(t, field.Typ.Field, amount)
133 next = setNextBit(field.Bits, 0)
134 }
135
136 if next == current {
137 return t
138 } else {
139 count := 0
140 current := getTimeValue(t, field.Typ.Field)
141 for ; current != next && count < maxAttempts; count++ {
142 t = elapseUntil(t, field.Typ, next)
143 current = getTimeValue(t, field.Typ.Field)
144 }
145
146 if count >= maxAttempts {
147 return time.Time{}
148 }
149
150 return t
151 }
152}
153
154func ParseCronExpression(expression string) (*CronExpression, error) {
155 if len(expression) == 0 {

Callers 1

nextMethod · 0.95

Calls 5

getTimeValueFunction · 0.85
setNextBitFunction · 0.85
getFieldMaxValueFunction · 0.85
addTimeFunction · 0.85
elapseUntilFunction · 0.85

Tested by

no test coverage detected