How to use the isPast function from date-fns
Find comprehensive JavaScript date-fns.isPast code examples handpicked from public code repositorys.
2 3 4 5 6 7 8 9
module.exports = { isExpired: token => { const { exp } = jwt.decode(token) || { exp: 0 }; const expires = new Date(exp * 1000); return isPast(expires); }, };
7
17
33
121 122 123 124 125 126 127 128 129 130
* @param {Object} campaign * @return {String} */ function parseCampaignStatus(campaign) { const endDate = campaign.end_date; if (endDate && dateFns.isPast(dateFns.parse(endDate))) { return config.statuses.closed; } return config.statuses.active; }
5
2
16
42 43 44 45 46 47 48 49 50
for (let index = 0; index < mutationsList.length; index++) { const mutation = mutationsList[index] if (mutation.type === 'childList') { const parsedDate = parseISO(this.settings.datetime) const overdue = isPast(parsedDate) const imminent = differenceInMinutes(parsedDate, new Date()) < this.settings.imminentOffset
3
6
8
98 99 100 101 102 103 104 105 106 107
exports.isFridayImpl = dateFns.isFriday exports.isFutureImpl = dateFns.isFuture exports.isLastDayOfMonthImpl = dateFns.isLastDayOfMonth exports.isLeapYearImpl = dateFns.isLeapYear exports.isMondayImpl = dateFns.isMonday exports.isPastImpl = dateFns.isPast exports.isSameDayImpl = dateFns.isSameDay exports.isSameHourImpl = dateFns.isSameHour exports.isSameISOWeekImpl = dateFns.isSameISOWeek exports.isSameISOYearImpl = dateFns.isSameISOYear
0
2
1
+ 16 other calls in file
145 146 147 148 149 150 151 152 153 154
return true; } const lastEvent = alert.events[0]; const timeout = add(new Date(lastEvent.createdAt), { seconds: alert.timeout }); return isPast(timeout); }); const { chartData, Datasets } = chart; const dateFormat = chart.getDataValue("dateFormat");
163
0
0
GitHub: stainlezzking/pik-am
40 41 42 43 44 45 46 47 48 49 50
const payPTinvestments = async function(plans) { for (i = 0; i < plans.length; i++) { const amount = ((plans[i].targetAmount * (plans[i].roi/100) * Math.floor(plans[i].lifetimeDuration / plans[i].paymentInterval)) + plans[i].deposits.reduce((o, c) => o += c.amount, 0)) / plans[i].users.length const expiry = datefns.addDays(plans[i].startDate, plans[i].lifetimeDuration) if (datefns.isToday(expiry) || datefns.isPast(expiry)) { await PTCLUSTER.updateOne({ _id: plans[i]._id }, { ended: true }) await USER.updateMany({ _id: { $in: plans[i].users.map(u => u.userId) } }, { $inc: { balance: amount }, $push: { activities: { title: " Partnership Payout #" + plans[i].id, body: "You earned $" + amount.toLocaleString() + " in your partnership Cluster ", type: "assets_sell" } }
0
0
0
+ 2 other calls in file
6 7 8 9 10 11 12 13 14 15 16 17 18
const checkIfOverdue = (dueDate) => { if (!dateRegex.test(dueDate)) return 'Date must be YYYY-MM-DD'; const due = dateFns.parseISO(dueDate); const isOverDue = dateFns.isPast(due); const distanceFromToday = dateFns.formatDistanceToNowStrict(due, { unit: 'day', });
0
0
0
date-fns.format is the most popular function in date-fns (3838 examples)