How to use the calendar-utils/date-adapters/moment.adapterFactory function in calendar-utils

To help you get started, we’ve selected a few calendar-utils 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 mattlewis92 / angular-calendar / projects / angular-calendar / src / date-adapters / moment / index.ts View on Github external
export function adapterFactory(moment): DateAdapter {
  return {
    ...baseAdapterFactory(moment),

    addWeeks(date: Date | number, amount: number): Date {
      return moment(date)
        .add(amount, 'weeks')
        .toDate();
    },

    addMonths(date: Date | number, amount: number): Date {
      return moment(date)
        .add(amount, 'months')
        .toDate();
    },

    subDays(date: Date | number, amount: number): Date {
      return moment(date)
        .subtract(amount, 'days')