Array.prototype.contains = function(obj) {
  var i = this.length;
  while (i--) {
    if (this[i] === obj) {
      return true;
    }
  }
  return false;
}

Date.prototype.isAfter = function(d) {
    return this.compareTo(d) > 0;
}

Date.prototype.isBefore = function(d) {
    return this.compareTo(d) < 0;
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}


var mmyy_re = /^((0[1-9])|(1[0-2]))\d\d$/;

function last_date(mmyy) {
    month = parseInt(mmyy.substring(0,1));
    year = 2000 + parseInt(mmyy.substring(2));

    if(month == 2) {
        if((year == 0) || (year % 4 != 0)) {
            return new Date(year, month, 28);
        } else {
            return new Date(year, month, 29);
        }
    } else if ([1, 3, 5, 7, 8, 10, 12].contains(month)) {
        return new Date(year, month, 31)
    } else {
        return new Date(year, month, 30)
    }
}

function is_expired(mmyy) {
    d = last_date(mmyy);
    return d.isBefore(Date.today());
}
