How to use the dayjs.isDayjs function in dayjs

To help you get started, we’ve selected a few dayjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github d2-projects / d2-admin / src / filters / module.date.js View on Github external
get (target, key) {
      if (dayjs.isDayjs(target)) {
        // 是 Dayjs 对象,正常返回
        return target[key]
      } else {
        // 不是 Dayjs 对象
        if (dayjs(target).isValid()) {
          // 尝试帮用户解析成 Dayjs 对象
          return dayjs(target)[key]
        } else {
          // 无法解析
          return function () {
            return '无效日期'
          }
        }
      }
    },
    set (target, key, value) {
github you-dont-need / You-Dont-Need-Momentjs / __tests__ / index.js View on Github external
it('Is a Date', () => {
    expect(moment.isDate(new Date())).toBeTruthy();
    expect(new Date() instanceof Date).toBeTruthy();
    expect(date.isDate(new Date())).toBeTruthy();
    expect(dayjs.isDayjs(dayjs())).toBeTruthy();
    expect(DateTime.local().isValid).toBeTruthy();
  });
});
github mathieustan / vue-datepicker / src / utils / Dates.js View on Github external
export function isAfterDate (date, afterDate, type = 'day') {
  if (type === 'year') {
    return Boolean(afterDate) && date > dayjs(afterDate, 'YYYY-MM-DD').get(type);
  }

  const selectedDate = dayjs.isDayjs(date) ? date : dayjs(date).startOf('day');
  return Boolean(afterDate) && selectedDate.isAfter(dayjs(afterDate).startOf('day'), type);
}
github mathieustan / vue-datepicker / src / utils / Dates.js View on Github external
export function generateDateRange (startDate, endDate, interval = 'day') {
  const start = dayjs.isDayjs(startDate) ? startDate : dayjs(startDate);
  const end = dayjs.isDayjs(endDate) ? endDate : dayjs(endDate);
  const diffBetweenDates = end.diff(start, interval);
  return [...Array(diffBetweenDates + 1).keys()].map(i => start.add(i, interval));
}
github mathieustan / vue-datepicker / src / utils / Dates.js View on Github external
export function generateDateRange (startDate, endDate, interval = 'day') {
  const start = dayjs.isDayjs(startDate) ? startDate : dayjs(startDate);
  const end = dayjs.isDayjs(endDate) ? endDate : dayjs(endDate);
  const diffBetweenDates = end.diff(start, interval);
  return [...Array(diffBetweenDates + 1).keys()].map(i => start.add(i, interval));
}
github mathieustan / vue-datepicker / src / utils / Dates.js View on Github external
export function isBeforeDate (date, beforeDate, type = 'day') {
  if (type === 'year') {
    return Boolean(beforeDate) && date < dayjs(beforeDate, 'YYYY-MM-DD').get(type);
  }

  const selectedDate = dayjs.isDayjs(date) ? date : dayjs(date).startOf('day');
  return Boolean(beforeDate) && selectedDate.isBefore(dayjs(beforeDate).startOf('day'), type);
}

dayjs

2KB immutable date time library alternative to Moment.js with the same modern API

MIT
Latest version published 3 months ago

Package Health Score

88 / 100
Full package analysis