schedule.scheduleJob(rule,async function(){ try { let arr=await (temp.findAsync()); for(let obj of arr) { let newDate=moment(obj.createdAt).add(30,"m"); if(moment().isAfter(newDate)) { let pathName=path.join(con.filePath,"temp",obj.name+".zip"); if(await (fs.existsAsync(pathName))) { await (fs.unlinkAsync(pathName)); } await (obj.removeAsync()); } } } catch (err) { console.log(err); } })
url: event.html_url, created_at: moment(event.created_at).format('MMMM Do YYYY'), is_pending: moment(event.created_at).isAfter(weekOld), user: { login: event.user.login,
const winbackCanBeSentForCancellationDate = (createdAt) => { const { minCancelledAt } = getCancelledAtMinMax() return moment(createdAt) .isAfter( moment(minCancelledAt).add(1, 'days') ) }
function _buildViewData(currentDate, notifications) { notifications.forEach((notification) => { if (!notification.expirationDate) { notification.expired = true; } else { const currentMoment = moment(currentDate).endOf('day'); const expirationMoment = moment(notification.expirationDate).endOf('day'); notification.expired = currentMoment.isAfter(expirationMoment); } }); return notifications; }
/** * @author Torrey Leonard <https://github.com/Ladinn> * @returns {Boolean} */ isExtendedOpenNow() { return moment().isAfter(this.getExtendedOpen()) && moment().isBefore(this.getExtendedClose()) }
// Check if time range contains now function time_range_contains({start, end, now}) { const moment_start = moment(start), moment_end = moment(end), moment_now = moment(now); if(moment_now.isAfter(moment_end) && moment_end.isBefore(moment_start)) { moment_end.add(1, 'day'); } else if (moment_now.isBefore(moment_end) && moment_start.isAfter(moment_end)) { moment_start.subtract(1, 'day'); } return moment.twix(moment_start, moment_end).contains(moment_now); }
const getValidResolvedToken = async (token, context) => { const resolvedToken = await resolve(token, context) if (resolvedToken && resolvedToken.expiresAt.isAfter(moment())) { return resolvedToken } return null }
/** * Checks if its the same dates after a date change and set the times if needed */ dateTimeStateVerification() { if (moment(this.state.startDate, 'ddd., MMM DD, YYYY').isSame(moment(this.state.endDate, 'ddd., MMM DD, YYYY'))) { if (moment(this.state.endTime, 'h:mm A').isAfter(moment(this.state.startTime, 'h:mm A'))) { //do nothing } else { this.setState({endTime: this.state.startTime}); } } else { //do nothing } }
const shouldUpdateTranslations = (fileCacheTime, fileLastUpdatedTime) => lastCacheTimestamp === null || moment(fileLastUpdatedTime).isAfter(fileCacheTime)
active() { return moment().isAfter(moment(this.start_date)) && moment().isBefore(moment(this.end_date)); }
async tokenExpired (token) { const expires = Env.get('TOKEN_EXPIRES', 60) // in mins return moment().isAfter(moment(token.created_at).add(expires, 'minutes')) }
const dateVerification = (startDate, endDate, date) => { if (moment(date, 'ddd., MMM DD, YYYY').isBefore(moment(startDate, 'ddd., MMM DD, YYYY'))) { return startDate; } else if(moment(date, 'ddd., MMM DD, YYYY').isAfter(moment(endDate, 'ddd., MMM DD, YYYY'))) { return endDate; } else { return date; } }
/** * @author Torrey Leonard <https://github.com/Ladinn> * @returns {Boolean} */ isOpenNow() { return moment().isAfter(this.getOpen()) && moment().isBefore(this.getClose()); }
const getValidResolvedToken = async (token, context) => { const resolvedToken = await resolve(token, context) if (resolvedToken && resolvedToken.expiresAt.isAfter(moment())) { return resolvedToken } return null }
const timeVerification = (startTime, endTime, time) => { if (moment(time, 'h:mm A').isBefore(moment(startTime, 'h:mm A'))) { return startTime; } else if (moment(time, 'h:mm A').isAfter(moment(endTime, 'h:mm A'))) { return endTime; } else { return time; } }