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);
    },
};
fork icon7
star icon17
watch icon33

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;
}
fork icon5
star icon2
watch icon16

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
fork icon3
star icon6
watch icon8

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
fork icon0
star icon2
watch icon1

+ 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");
fork icon163
star icon0
watch icon0

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" } }
fork icon0
star icon0
watch icon0

+ 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',
  });
fork icon0
star icon0
watch icon0

Other functions in date-fns

Sorted by popularity

function icon

date-fns.format is the most popular function in date-fns (3838 examples)