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 ); }
updateHeartBeat(queryKey) { const key = this.redisHash(queryKey); if (this.heartBeat[key]) { this.heartBeat[key] = { key, order: new Date().getTime() }; } }
function fiveMinutesAgo() { var dateOne = new Date() dateOne.setTime(dateOne.getTime() - (1000 * 60 * 5)) // add 5 minutes return dateOne.toUTCString() }
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 }
UNSAFE_componentWillReceiveProps( nextProps ) { if ( ! nextProps.lockExpires || nextProps.lockExpires === this.props.lockExpires ) { return; } // Add 2 seconds to the refresh clock to prevent race conditions this._refresh && clearTimeout( this._refresh ); this._refresh = setTimeout( () => this.forceUpdate(), nextProps.lockExpires - new Date().getTime() + 2000 ); }
function _getUUID(test) { if (test.uuid) { return test.uuid; } if (test.ctx && test.ctx.test.uuid) { return test.ctx.test.uuid; } return Math.floor(new Date().getTime() / 1000); }
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 }
function shouldHidePlayerControls () { return this.location.url() === 'player' && this.playing.mouseStationarySince !== 0 && new Date().getTime() - this.playing.mouseStationarySince > 2000 && !this.playing.mouseInControls && !this.playing.isPaused && this.playing.location === 'local' && this.playing.playbackRate === 1 }
async getToken() { if (this.authToken && this.authToken.expires > new Date().getTime()) { return `_dremio${this.authToken.token}`; } const { data } = await axios.post(`${this.config.url}/apiv2/login`, { userName: this.config.user, password: this.config.password }); this.authToken = data; return `_dremio${this.authToken.token}`; }
export function isDateEqual( localDateEdit, savedDate ) { // if the local date edit is false, it means we are asking the server to reset // the scheduled date to "now". In that case, we accept the date value returned // by the server and consider the edit saved. if ( localDateEdit === false ) { return true; } return localDateEdit && new Date( localDateEdit ).getTime() === new Date( savedDate ).getTime(); }
function createCacheObject(status, headers, data, encoding) { return { status: status, headers: filterBlacklistedHeaders(headers), data: data, encoding: encoding, timestamp: new Date().getTime() / 1000, // seconds since epoch. This is used to properly decrement max-age headers in cached responses. } }
function delCookie(name) { var exp = new Date(); exp.setTime(exp.getTime() - 1); var cval=getCookie(name); if(cval!=undefined && cval!=null) { document.cookie= name + "="+cval+";expires="+exp.toGMTString()+";path=/;"; } }
export default function isExpired(recordedOn, expiresIn) { if (recordedOn && expiresIn) { return ( new Date() > new Date(new Date(recordedOn).getTime() + dehumanizeTime(expiresIn)) ); } return false; }
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 }
function inFiveMinutes() { var dateOne = new Date() dateOne.setTime(dateOne.getTime() + (1000 * 60 * 5)) // add 5 minutes return dateOne.toUTCString() }