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

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

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

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



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

示例1: getWeekViewEventOffset

export function getWeekViewEventOffset(
    { event, startOfWeek, excluded = [] }: { event: CalendarEvent, startOfWeek: Date, excluded?: number[] }): number {
    if (event.start < startOfWeek) {
        return 0;
    }
    const distance: number = dateFns.differenceInDays(event.start, startOfWeek);
    return distance - getExcludedDays({ startDate: startOfWeek, days: distance, excluded });
}
开发者ID:MagicAardvark,项目名称:novo-elements,代码行数:8,代码来源:CalendarUtils.ts


示例2: 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


示例3: getWeekViewEventSpan

function getWeekViewEventSpan(
    { event, offset, startOfWeek, excluded }: { event: CalendarEvent, offset: number, startOfWeek: Date, excluded: number[] }): number {
    const begin: Date = event.start < startOfWeek ? startOfWeek : event.start;
    let span: number = 1;
    if (event.end) {
        span = dateFns.differenceInDays(dateFns.addMinutes(dateFns.endOfDay(event.end), 1), dateFns.startOfDay(begin));
    }
    const totalLength: number = offset + span;
    if (totalLength > DAYS_IN_WEEK) {
        span = DAYS_IN_WEEK - offset;
    }
    return span - getExcludedDays({ startDate: begin, days: span, excluded });
}
开发者ID:MagicAardvark,项目名称:novo-elements,代码行数:13,代码来源:CalendarUtils.ts


示例4: differenceInDays

export function differenceInDays(dateLeft: Date, dateRight: Date): number {
  return _differenceInDays(dateLeft, dateRight);
}
开发者ID:christophelevis,项目名称:sonarqube,代码行数:3,代码来源:dates.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript date-fns.endOfDay函数代码示例发布时间:2022-05-25
下一篇:
TypeScript date-fns.addMinutes函数代码示例发布时间: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