Date.prototype.is_leap = function()
{
    var year = this.getFullYear();
    return ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0);
}

Date.prototype.month_days = function()
{
    var month = this.getMonth() + 1;
    if(2 == month)
    {
        return (this.is_leap() ? 29 : 28);
    }
    else if(4 == month || 6 == month || 9 == month || 11 == month)
    {
        return 30;
    }
    else
    {
        return 31;
    }
}

