# File cron/lib/symbiosis/crontab.rb, line 330
    def next_due(now = DateTime.now)
      time      = now
      orig_time = time

      while !ready?(time)
        # find the next minute that matches
        unless min.include?(time.min)
          ind = (min + [time.min]).sort.index(time.min)

          if min.length == ind
            # Roll on time to the beginning of the next hour
            time += (60 - time.min + min.first)/ (60*24.0)
          else
            time += (min[ind] - time.min) / (60 * 24.0)
          end
        end

        # find the next hour that matches
        unless hour.include?(time.hour)
          ind = (hour + [time.hour]).sort.index(time.hour)

          if hour.length == ind
            # Roll on time to the beginning of the next our
            time += (24 - time.hour + hour.first)/ 24.0
          else
            time += (hour[ind] - time.hour) / 24.0
          end
        end  

        # find the next hour that matches
        unless mday.include?(time.mday)
          ind = (mday + [time.mday]).sort.index(time.mday)

          if mday.length == ind
            # Roll on time to the beginning of the next our
            time = (time >> 1) - time.mday + mday.first
          else
            time += mday[ind] - time.mday
          end
        end  

        # The next month that matches
        unless mon.include?(time.mon)
          ind = (mon + [time.mon]).sort.index(time.mon)

          if mon.length == ind
            # Roll on time to the beginning of the next our
            time = time >> (12 - time.mon + mon.first)
          else
            time = time >> (mon.first - time.mon)
          end
        end

        unless wday.include?(time.wday)
          ind = (wday + [time.wday]).sort.index(time.wday)
          if wday.length == ind
            # Roll on time to the beginning of the next week, and add the first day.
            time = time + (7 - time.wday + wday.first)
          else
            time = time + (wday.first - time.wday)
          end
        end

        # Break if we get 30 years into the future!
        if time > (orig_time >> 360)
          time = nil
          break
        end
      end

      time
    end