const dateToTimestamp = function (date) { var iteration = 0 while (1) { try { switch (iteration++) { ///// ISO String case 0: return Math.floor(Date.parse(date) / 1000); ///// Timestamp string case 2: if (typeof(date) != 'string') continue; date = parseInt(date); break; ///// Timestamp integer case 1: if (typeof(date) != 'integer') continue; // if (date > 0xFFFFFFFF) return Math.floor(date / 1000) else return date; default: return undefined } } catch (e) { continue } } } const unixTimestamp = function () { return Math.floor(Date.now() / 1000) } module.exports = { dateToTimestamp, unixTimestamp, }