lib/hypertimer.js
function toTimestamp(date) {
    var value =
        (typeof date === 'number') ? date :           // number
        (date instanceof Date)     ? date.valueOf() : // Date
        new Date(date).valueOf();                     // ISOString, momentjs, ...

    if (isNaN(value)) {
      throw new TypeError('Invalid date ' + JSON.stringify(date) + '. ' +
          'Date, number, or ISOString expected');
    }

    return value;
  }
function toTimestamp(date) {
    var value =
        (typeof date === 'number') ? date :           // number
        (date instanceof Date)     ? date.valueOf() : // Date
        new Date(date).valueOf();                     // ISOString, momentjs, ...

    if (isNaN(value)) {
      throw new TypeError('Invalid date ' + JSON.stringify(date) + '. ' +
          'Date, number, or ISOString expected');
    }

    return value;
  }
function toTimestamp ( date ) { var value = ( typeof date === 'number' ) ? date : // number ( date instanceof Date ) ? date . valueOf ( ) : // Date new Date ( date ) . valueOf ( ) ; // ISOString, momentjs, ... if ( isNaN ( value ) ) { throw new TypeError ( 'Invalid date ' + JSON . stringify ( date ) + '. ' + 'Date, number, or ISOString expected' ) ; } return value ; }
Convert a Date, number, or ISOString to a number timestamp,
and validate whether it's a valid Date. The number Infinity is also
accepted as a valid timestamp
@param {Date | number | string} date
@return {number} Returns a unix timestamp, a number
Convert a Date number or ISOString to a number timestamp and validate whether it s a valid Date . The number Infinity is also accepted as a valid timestamp