| 398 | } |
| 399 | |
| 400 | func 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 | |
| 421 | func getFieldMaxValue(t time.Time, fieldType fieldType) int { |
| 422 | |