function toMomentObject(date) { if (moment.isMoment(date)) return date; if (date instanceof Date) return moment(date); var regex = new RegExp(/([0-9]{4})-([0-9]{2})-([0-9]{2})/); if(_.isString(date) && !!(date.match(regex))) return moment(date, "YYYY-MM-DD"); throw new Error('Unknown date format. Please use Date() object or String() with format YYYY-MM-DD.'); }
/** * prepare the given object by only returning * the given columns/properties and formatting * special properties like moment instances * @param obj * @param columns * @returns {Array} */ prepare(obj = {}, columns = []) { return columns.map(column => { if (moment.isMoment(obj[column])) return obj[column].format(this.config.get('dateFormat')); if (obj[column] === undefined || obj[column] === null) return ''; return obj[column]; }); }
this.emit('crashed'); if (moment.isMoment(this.lastCrash) && moment(this.lastCrash).add(60, 'seconds').isAfter(moment())) { this.setCrashTime(); this.log.warn(props, 'Server detected as crashed but has crashed within the last 60 seconds; aborting reboot.');