class Rufus::Scheduler::CronLine

def parse_weekdays(item)

def parse_weekdays(item)
  return nil if item == '*'
  weekdays = nil
  monthdays = nil
  item.downcase.split(',').each do |it|
    WEEKDAYS.each_with_index { |a, i| it.gsub!(/#{a}/, i.to_s) }
    it = it.gsub(/([^#])l/, '\1#-1')
      # "5L" == "5#-1" == the last Friday
    if m = it.match(/\A(.+)#(l|-?[12345])\z/)
      fail ArgumentError.new(
        "ranges are not supported for monthdays (#{it})"
      ) if m[1].index('-')
      it = it.gsub(/#l/, '#-1')
      (monthdays ||= []) << it
    else
      fail ArgumentError.new(
        "invalid weekday expression (#{item})"
      ) if it !~ /\A0*[0-7](-0*[0-7])?\z/
      its = it.index('-') ? parse_range(it, 0, 7) : [ Integer(it) ]
      its = its.collect { |i| i == 7 ? 0 : i }
      (weekdays ||= []).concat(its)
    end
  end
  weekdays = weekdays.uniq.sort if weekdays
  [ weekdays, monthdays ]
end