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

Function with

cron.go:400–419  ·  view source on GitHub ↗
(t time.Time, field cronField, value int)

Source from the content-addressed store, hash-verified

398}
399
400func with(t time.Time, field cronField, value int) time.Time {
401 switch field {
402 case cronFieldNanoSecond:
403 return time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), value, time.Local)
404 case cronFieldSecond:
405 return time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), value, t.Nanosecond(), time.Local)
406 case cronFieldMinute:
407 return time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), value, t.Second(), t.Nanosecond(), time.Local)
408 case cronFieldHour:
409 return time.Date(t.Year(), t.Month(), t.Day(), value, t.Minute(), t.Second(), t.Nanosecond(), time.Local)
410 case cronFieldDayOfMonth:
411 return time.Date(t.Year(), t.Month(), value, t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), time.Local)
412 case cronFieldMonth:
413 return time.Date(t.Year(), time.Month(value), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), time.Local)
414 case cronFieldDayOfWeek:
415 return t.AddDate(0, 0, value-int(t.Weekday()))
416 }
417
418 panic("unreachable code!")
419}
420
421func getFieldMaxValue(t time.Time, fieldType fieldType) int {
422

Callers 1

elapseUntilFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected