const Appointment = {
    create : function( p )
    {
        Object.assign( this, p.getAll() );
    },

    getMomentOfStart : function()
    {
        let mStart = moment();

        if ( this.start_dt && this.start_dt.hasOwnProperty( 'date' ) )
        {
            mStart = moment( this.start_dt.date );
        }

        return mStart;
    },

    isOver : function()
    {
        return this.getMomentOfEnd().isBefore( moment() );
    },

    getMomentOfEnd : function()
    {
        let mEnd = moment();

        if ( this.end_dt && this.end_dt.hasOwnProperty( 'date' ) )
        {
            mEnd = moment( this.end_dt.date );
        }

        return mEnd;
    },

    getNumAcceptedAttendees : function()
    {
        var num = 0;

        for ( var i = 0 ; i < this.attendees.length; i++ )
        {
            if ( this.attendees[ i ][ 'has_attended' ] === 'attended' )
            {
                num++;
            }
        }

        return num;
    },

    getPriceFactor : function()
    {
        return this.price_factor / 100;
    },

    setAttendees : function( atts )
    {
        this.attendees = atts ? atts : [];
    },


    destroy : function()
    {

    }
};

export { Appointment };