当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript date-fns.addDays函数代码示例

本文整理汇总了TypeScript中date-fns.addDays函数的典型用法代码示例。如果您正苦于以下问题:TypeScript addDays函数的具体用法?TypeScript addDays怎么用?TypeScript addDays使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了addDays函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: async

 async(inject([MatDialogRef], (dialogRef: MatDialogRef<any>) => {
   const originalEventsLength = component.events.length;
   const sortEventsSpy = spyOn(component, 'sortEvents');
   component.repeatLesson(component.events[0]);
   dialogRef.close({ repeatCount: 2, repeatInterval: 100 });
   fixture.detectChanges();
   const newEventsLength = component.events.length;
   expect(newEventsLength).toBe(originalEventsLength + 2);
   expect(component.events[newEventsLength - 1].start).toEqual(addDays(component.events[0].start, 200));
   expect(component.events[newEventsLength - 2].start).toEqual(addDays(component.events[0].start, 100));
   expect(sortEventsSpy).toHaveBeenCalled();
 })));
开发者ID:vgebrev,项目名称:Tesli,代码行数:12,代码来源:calendar.component.spec.ts

示例2: times

 times(getDaysInMonth(date), () => {
   const day = new Date(monthDate);
   if (showWeekend === true || !isWeekend(day)) {
     days.push(new CalendarDay(day, false, isSameDay(monthDate, new Date())));
   }
   monthDate = addDays(monthDate, 1);
 });
开发者ID:w11k,项目名称:calendar-for-trello,代码行数:7,代码来源:calendar-days.service.ts

示例3: minDate

    (weekRange) => {
      const end = minDate([parseISO(weekRange.end), date]);
      for (let current = parseISO(weekRange.start); current <= end; current = addDays(current, 7)) {
        if (isEqual(current, date)) return true;
      }

      return false;
    },
开发者ID:nusmodifications,项目名称:nusmods,代码行数:8,代码来源:timetables.ts

示例4: flow

  loadWeek: flow(function* loadWeek() {

    self.loading = true;

    const start = new Date();
    const end = addDays(start, 5);

    const query = (fetchPolicy: FetchPolicy = 'network-only') => new Promise((resolve) => {
      client.query({
        fetchPolicy,
        query: fetchMoviesForWeekQuery,
        variables: {
          start: start.toISOString().substr(0, 10),
          end: end.toISOString().substr(0, 10),
        },
      })
      .then(resolve);
      if (fetchPolicy === 'network-only') {
        setTimeout(() => resolve({ error: { message: 'Network error' } }), 5000);
      }
    });

    let result = yield query();
    const isNetworkError = result.error && result.error.message.includes('Network error');

    if (isNetworkError) {
      result = yield query('cache-only');
    }

    self.isOffline = isNetworkError;
    self.isCache = isNetworkError && result.data;

    if (!result.data) {
      return;
    }
    result.data.allMovies.map(Movies.addPartialMovie);

    result.data.allMovies.forEach((movie: IMovieFromDb) => {
      movie.showtimes.forEach((showtime) => {
        const dateKey = addHours(showtime.playingAt, -4).toISOString().substr(0, 10);

        if (!self.dates.has(dateKey)) {
          self.dates.put({
            date: dateKey,
            movies: {},
          });
        }

        const dateOf = self.dates.get(dateKey);
        if (dateOf) {
          dateOf.movies.put({ id: movie.id, movie: movie.id });
        }
      });
    });

    self.loaded = true;
    self.loading = false;
  }),
开发者ID:birkir,项目名称:kvikmyndr-app,代码行数:58,代码来源:in-theaters.ts

示例5: Date

  () => {
    const viewDate = new Date(2018, 6, 1);
    const newDate = addDays(viewDate, 1);
    component.activeDayIsOpen = true;
    component.viewDate = viewDate;
    component.selectDay({ date: newDate, events: [] });

    expect(component.activeDayIsOpen).toBeFalsy();
  });
开发者ID:vgebrev,项目名称:Tesli,代码行数:9,代码来源:calendar.component.spec.ts

示例6: createSchedule

function createSchedule(props: Partial<Schedule> & {transaction_date: Date} = {transaction_date: new Date()}): Schedule & {transaction_date: Date} {
	return Object.assign({
		transaction_date: new Date(),
		frequency: "Monthly" as ScheduleFrequency,
		next_due_date: addDays(startOfDay(new Date()), 3),
		auto_enter: false,
		autoFlag: false,
		overdue_count: 0,
		estimate: false
	}, props);
}
开发者ID:scottohara,项目名称:loot,代码行数:11,代码来源:index.ts

示例7: test

function test() {

  addDays(new Date(), 5);
  closestIndexTo(new Date(), [new Date(), new Date()]);
  addHours(new Date(), 5);
  differenceInCalendarWeeks(new Date(), new Date());
  differenceInCalendarWeeks(new Date(), new Date(), {weekStartsOn: 1});
  max(new Date(), new Date());
  isDate({});

}
开发者ID:KostyaTretyak,项目名称:DefinitelyTyped,代码行数:11,代码来源:date-fns-tests.ts

示例8: getMonthView

export function getMonthView({
  events = [],
  viewDate,
  weekStartsOn,
  excluded = [],
}: {
  events?: CalendarEvent[];
  viewDate: Date;
  weekStartsOn: number;
  excluded?: number[];
}): MonthView {
  if (!events) {
    events = [];
  }

  const start: Date = dateFns.startOfWeek(dateFns.startOfMonth(viewDate), { weekStartsOn });
  const end: Date = dateFns.endOfWeek(dateFns.endOfMonth(viewDate), { weekStartsOn });
  const eventsInMonth: CalendarEvent[] = getEventsInPeriod({
    events,
    periodStart: start,
    periodEnd: end,
  });
  const days: MonthViewDay[] = [];
  for (let i: number = 0; i < dateFns.differenceInDays(end, start) + 1; i++) {
    const date: Date = dateFns.addDays(start, i);
    if (!excluded.some((e) => date.getDay() === e)) {
      const day: MonthViewDay = getWeekDay({ date }) as MonthViewDay;
      const calEvents: CalendarEvent[] = getEventsInPeriod({
        events: eventsInMonth,
        periodStart: dateFns.startOfDay(date),
        periodEnd: dateFns.endOfDay(date),
      });
      day.inMonth = dateFns.isSameMonth(date, viewDate);
      day.events = calEvents;
      day.badgeTotal = calEvents.length;
      days.push(day);
    }
  }

  const totalDaysVisibleInWeek: number = DAYS_IN_WEEK - excluded.length;
  const rows: number = Math.floor(days.length / totalDaysVisibleInWeek);
  const rowOffsets: number[] = [];
  for (let i: number = 0; i < rows; i++) {
    rowOffsets.push(i * totalDaysVisibleInWeek);
  }

  return {
    rowOffsets,
    totalDaysVisibleInWeek,
    days,
  };
}
开发者ID:bullhorn,项目名称:novo-elements,代码行数:52,代码来源:CalendarUtils.ts


注:本文中的date-fns.addDays函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。