scheduleRefresh( props ) { if ( ! this.shouldRefresh( props ) ) { return; } // Request a refresh one second before the current lock expires this._refresh = setTimeout( () => { this._refresh = null; this.requestLock( props ); }, props.expires - new Date().getTime() - 1000 ); }
// 26 Feb 16:19:34 function timestamp() { var d = new Date(); var time = [ pad( d.getHours() ), pad( d.getMinutes() ), pad( d.getSeconds() ) ].join( ':' ); return [ d.getDate(), months[ d.getMonth() ], time ].join( ' ' ); }
updateHeartBeat(queryKey) { const key = this.redisHash(queryKey); if (this.heartBeat[key]) { this.heartBeat[key] = { key, order: new Date().getTime() }; } }
constructor ({componentID, name, description = '', status, order = Math.floor(new Date().getTime() / 1000)}) { this.componentID = componentID this.name = name this.description = description this.status = status this.order = order }
constructor ({maintenanceID, name, status, startAt, endAt, createdAt = new Date().toISOString(), updatedAt = new Date().toISOString()}) { super() this.maintenanceID = maintenanceID this.name = name this.status = status this.startAt = startAt this.endAt = endAt this.createdAt = createdAt this.updatedAt = updatedAt }
function formatDate() { var date = new Date(); var result = []; result.push(date.getFullYear()); result.push(padding(date.getMonth() + 1)); result.push(padding(date.getDate())); result.push(padding(date.getHours())); result.push(padding(date.getMinutes())); result.push(padding(date.getSeconds())); result.push(paddingMS(date.getMilliseconds())); return result.join(''); }
it('can get expiration time in string format', done => { // Make mock request const timeStr = '2015-03-19T22:05:08Z'; const body = { expiration_time: timeStr, }; const time = PushController.getExpirationTime(body); expect(time).toEqual(new Date(timeStr).valueOf()); done(); });
const buildDates = () => { const currDate = new Date() const today = `${currDate.getUTCFullYear()}-${currDate.getUTCMonth() + 1}-${currDate.getUTCDate()}` currDate.setDate(currDate.getDate() - 1) const yesterday = `${currDate.getUTCFullYear()}-${currDate.getUTCMonth() + 1}-${currDate.getUTCDate()}` return [yesterday, today] }
const getDateObject = (dateString) => { const date = new Date(dateString) // Thanks to https://stackoverflow.com/questions/1353684/detecting-an-invalid-date-date-instance-in-javascript if (Object.prototype.toString.call(date) === '[object Date]' && isNaN(date.getTime())) { throw new Error(`invalid date string ${dateString}`) } return date }
// Returns a promise function makeTimeObject(start, i) { const time = new Date(); time.setSeconds(start.getSeconds() + i); const item = new TestObject({ name: 'item' + i, time: time }); return item.save(); }
function fiveMinutesAgo() { var dateOne = new Date() dateOne.setTime(dateOne.getTime() - (1000 * 60 * 5)) // add 5 minutes return dateOne.toUTCString() }
export default function isExpired(recordedOn, expiresIn) { if (recordedOn && expiresIn) { return ( new Date() > new Date(new Date(recordedOn).getTime() + dehumanizeTime(expiresIn)) ); } return false; }
constructor ({incidentID, name, status, createdAt = new Date().toISOString(), updatedAt = new Date().toISOString()}) { super() this.incidentID = incidentID this.name = name this.status = status this.createdAt = createdAt this.updatedAt = updatedAt }
constructor ({maintenanceID, maintenanceUpdateID, maintenanceStatus, message = '', createdAt = new Date().toISOString(), updatedAt = new Date().toISOString()}) { super() this.maintenanceID = maintenanceID this.maintenanceUpdateID = maintenanceUpdateID this.maintenanceStatus = maintenanceStatus this.message = message this.createdAt = createdAt this.updatedAt = updatedAt }
const getDateObject = (dateString) => { const date = new Date(dateString) // Thanks to https://stackoverflow.com/questions/1353684/detecting-an-invalid-date-date-instance-in-javascript if (Object.prototype.toString.call(date) === '[object Date]' && isNaN(date.getTime())) { throw new Error(`invalid date string ${dateString}`) } return date }