code: function(year, month, rules) {
        var daysInMonth = ICAL.Time.daysInMonth(month, year);
  
        // XXX: This is probably bad for performance to allocate
        //      a new array for each month we scan, if possible
        //      we should try to optimize this...
        var newRules = [];
  
        var ruleIdx = 0;
        var len = rules.length;
        var rule;
  
        for (; ruleIdx < len; ruleIdx++) {
          rule = rules[ruleIdx];
  
          // if this rule falls outside of given
          // month discard it.
          if (Math.abs(rule) > daysInMonth) {
            continue;
          }
  
          // negative case
          if (rule < 0) {
            // we add (not subtract its a negative number)
            // one from the rule because 1 === last day of month
            rule = daysInMonth + (rule + 1);
          } else if (rule === 0) {
            // skip zero its invalid.
            continue;
          }
  
          // only add unique items...
          if (newRules.indexOf(rule) === -1) {
            newRules.push(rule);
          }
  
        }
  
        // unique and sort
        return newRules.sort(function(a, b) { return a - b; });
      }
docs: Normalize each by day rule for a given year/month.
  Takes into account ordering and negative rules
  
  @private
  @param {Number} year         Current year.
  @param {Number} month        Current month.
  @param {Array}  rules        Array of rules.
  
  @return {Array} sorted and normalized rules.
  Negative rules will be expanded to their
  correct positive values for easier processing.