// render the date in a flexible format
Date.prototype.format = function( strFormat )
{
    if ( strFormat === undefined )
        strFormat = DATE_FORMAT;

    var days = this.getDate();

    if ( strFormat == "mmm d, 'YY" )
    {
        var month = MONTHS[this.getMonth()];
        var year = this.getFullYear()-2000;
        if ( year < 10 )
            year = "0" + year;
        return month + " " + days + ", '" + year;
    }

    else if ( strFormat == "mmm d" )
    {
        var month = MONTHS[this.getMonth()];
        return month + " " + days;
    }

    else if ( strFormat == "YYYY-mmm-dd" ) {
        if ( days < 10 )
            days = "0" + days;
        var month = MONTHS[this.getMonth()];
        return this.getFullYear() + "-" + month + "-" + days;
    }

    else  // should be YYYY-mm-dd
    {
        if ( days < 10 )
            days = "0" + days;
        var month = this.getMonth()+1;
        if ( month < 10 )
            month = "0" + month;
        return this.getFullYear() + "-" + month + "-" + days;
    }
};

// get the number of days since January 01
Date.prototype.getDayOfYear = function()
{
    var onejan = new Date( this.getFullYear(), 0, 1 );
    return Math.ceil( (this - onejan) / 86400000 );
};

// return a new date with the hours/minutes/days set to zero
Date.prototype.getMidnight = function()
{
    return new Date( this.getFullYear(), this.getMonth(), this.getDate() );
};

// constructor for an outing object
function Outing( outing ) 
{
    $.extend( true, this, outing );
};

Outing.prototype.getName = function() 
{
    return getOutingName( this );
};
Outing.prototype.getDate = function() 
{
    return new Date( this.date );
};
Outing.prototype.formatDate = function() 
{
    return this.getDate().format();
};
Outing.prototype.formatDateRange = function() 
{
    return formatOutingDateRange( this );
};

