• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript date-fns.addHours函数代码示例发布时间:2022-05-25
下一篇:
TypeScript rbtree.RBTree类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap