Source

dateTime/compareISOTimestamp.js

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 *
 * If this is used in Array.sort(), dates will be sorted from latest to earliest
 *
 * @param {string} a ISO-timestamp
 * @param {string} b ISO-timestamp
 *
 * @returns {number}
 *   return -1 if a is before b
 *   return 1 if a is after b
 *   else return 0
 * @category dateTime
 * @module compareISOTimestamp
 */
var compareISOTimestamp = function (a, b) {
    var aDate = new Date(a);
    var bDate = new Date(b);
    var isABeforeB = bDate > aDate;
    var isAAfterB = aDate > bDate;
    return isABeforeB ? -1 : isAAfterB ? 1 : 0;
};
exports.default = compareISOTimestamp;