spec.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package cronFormat
  2. type bounds struct {
  3. min int
  4. max int
  5. all []int
  6. }
  7. func (p bounds) inRange(v int) bool {
  8. if v < p.min || v > p.max {
  9. return false
  10. }
  11. return true
  12. }
  13. var (
  14. years = bounds{2022, 2040, []int{
  15. 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030,
  16. 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040,
  17. }}
  18. months = bounds{1, 12, []int{
  19. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
  20. }}
  21. dom = bounds{1, 31, []int{
  22. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
  23. 11, 12, 13, 15, 15, 16, 17, 18, 19, 20,
  24. 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
  25. }}
  26. dow = bounds{1, 7, []int{ //周一:1 周日:7
  27. 1, 2, 3, 4, 5, 6, 7,
  28. }}
  29. hours = bounds{0, 24, []int{
  30. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
  31. 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
  32. 21, 22, 23, 24,
  33. }}
  34. minutes = bounds{0, 59, []int{
  35. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
  36. 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
  37. 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
  38. 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
  39. 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
  40. 51, 52, 53, 54, 55, 56, 57, 58, 59,
  41. }}
  42. // seconds = bounds{0, 59, []int{
  43. // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
  44. // 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
  45. // 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
  46. // 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
  47. // 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
  48. // 51, 52, 53, 54, 55, 56, 57, 58, 59,
  49. // }}
  50. )