var entry = require('../util/entry');
var order = require('./order');

function date(options){
    if (options === order.DESC) {
        return function (a, b) {
            var dateA = entry.effectiveDate(a);
            var dateB = entry.effectiveDate(b);

            return dateB - dateA;
        }
    }
    else {
        return function (a, b) {
            var dateA = entry.effectiveDate(a);
            var dateB = entry.effectiveDate(b);

            return dateA - dateB;
        }
    }
}

module.exports = date;