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


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

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


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

示例1: isWithinRange

      .filter(it => {
        // pre filter cards: Only show cards that are in the calendar range
        const firstRelevantDate = calState.days[0];
        const lastRelevantDate = calState.days[calState.days.length - 1];

        if (!firstRelevantDate || !lastRelevantDate) {
          return [];
        }

        return isWithinRange(it.due, firstRelevantDate.date, endOfDay(lastRelevantDate.date));
      });
开发者ID:w11k,项目名称:calendar-for-trello,代码行数:11,代码来源:selects.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: getDayViewHourGrid

export function getDayViewHourGrid({
  viewDate,
  hourSegments,
  dayStart,
  dayEnd,
}: {
  viewDate: Date;
  hourSegments: number;
  dayStart: any;
  dayEnd: any;
}): DayViewHour[] {
  const hours: DayViewHour[] = [];

  const startOfView: Date = dateFns.setMinutes(dateFns.setHours(dateFns.startOfDay(viewDate), dayStart.hour), dayStart.minute);
  const endOfView: Date = dateFns.setMinutes(
    dateFns.setHours(dateFns.startOfMinute(dateFns.endOfDay(viewDate)), dayEnd.hour),
    dayEnd.minute,
  );
  const segmentDuration: number = MINUTES_IN_HOUR / hourSegments;
  const startOfViewDay: Date = dateFns.startOfDay(viewDate);

  for (let i: number = 0; i < HOURS_IN_DAY; i++) {
    const segments: DayViewHourSegment[] = [];
    for (let j: number = 0; j < hourSegments; j++) {
      const date: Date = dateFns.addMinutes(dateFns.addHours(startOfViewDay, i), j * segmentDuration);
      if (date >= startOfView && date < endOfView) {
        segments.push({
          date,
          isStart: j === 0,
        });
      }
    }
    if (segments.length > 0) {
      hours.push({ segments });
    }
  }

  return hours;
}
开发者ID:bullhorn,项目名称:novo-elements,代码行数:39,代码来源:CalendarUtils.ts

示例5: constructor

 /**
  * Constructor
  *
  * @param data
  */
 constructor(data?)
 {
     data = data || {};
     this.start = new Date(data.start) || startOfDay(new Date());
     this.end = new Date(data.end) || endOfDay(new Date());
     this.title = data.title || '';
     this.color = {
         primary  : data.color && data.color.primary || '#1e90ff',
         secondary: data.color && data.color.secondary || '#D1E8FF'
     };
     this.draggable = data.draggable;
     this.resizable = {
         beforeStart: data.resizable && data.resizable.beforeStart || true,
         afterEnd   : data.resizable && data.resizable.afterEnd || true
     };
     this.actions = data.actions || [];
     this.allDay = data.allDay || false;
     this.cssClass = data.cssClass || '';
     this.meta = {
         location: data.meta && data.meta.location || '',
         notes   : data.meta && data.meta.notes || ''
     };
 }
开发者ID:karthik12ui,项目名称:fuse-angular-full,代码行数:28,代码来源:event.model.ts

示例6:

    .map((entry: WeekViewEvent) => {
      const startOfView: Date = dateFns.setMinutes(dateFns.setHours(dateFns.startOfDay(entry.event.start), dayStart.hour), dayStart.minute);
      const endOfView: Date = dateFns.setMinutes(
        dateFns.setHours(dateFns.startOfMinute(dateFns.endOfDay(entry.event.start)), dayEnd.hour),
        dayEnd.minute,
      );

      const eventStart: Date = entry.event.start;
      const eventEnd: Date = entry.event.end || eventStart;

      const hourHeightModifier: number = (hourSegments * segmentHeight) / MINUTES_IN_HOUR;

      if (eventStart > startOfView) {
        entry.top += dateFns.differenceInMinutes(eventStart, startOfView);
      }

      entry.top *= hourHeightModifier;

      const startsBeforeDay: boolean = eventStart < startOfView;
      const endsAfterDay: boolean = eventEnd > endOfView;

      const startDate: Date = startsBeforeDay ? startOfView : eventStart;
      const endDate: Date = endsAfterDay ? endOfView : eventEnd;

      let height: number = dateFns.differenceInMinutes(endDate, startDate);

      if (!entry.event.end) {
        height = segmentHeight;
      } else {
        height *= hourHeightModifier;
      }

      entry.height = height;

      return entry;
    });
开发者ID:bullhorn,项目名称:novo-elements,代码行数:36,代码来源:CalendarUtils.ts

示例7: getDayView

export function getDayView({ events = [], viewDate, hourSegments, dayStart, dayEnd, eventWidth, segmentHeight }: GetDayViewArgs): DayView {
  if (!events) {
    events = [];
  }

  const startOfView: Date = dateFns.setMinutes(dateFns.setHours(dateFns.startOfDay(viewDate), dayStart.hour), dayStart.minute);
  const endOfView: Date = dateFns.setMinutes(
    dateFns.setHours(dateFns.startOfMinute(dateFns.endOfDay(viewDate)), dayEnd.hour),
    dayEnd.minute,
  );
  const previousDayEvents: DayViewEvent[] = [];

  const dayViewEvents: DayViewEvent[] = getEventsInTimeRange(
    getEventsInPeriod({
      events: events.filter((event: CalendarEvent) => !event.allDay),
      periodStart: startOfView,
      periodEnd: endOfView,
    }),
    dayStart,
    dayEnd,
  )
    .sort((eventA: CalendarEvent, eventB: CalendarEvent) => {
      return eventA.start.valueOf() - eventB.start.valueOf();
    })
    .map((event: CalendarEvent) => {
      const eventStart: Date = event.start;
      const eventEnd: Date = event.end || eventStart;
      const startsBeforeDay: boolean = eventStart < startOfView;
      const endsAfterDay: boolean = eventEnd > endOfView;
      const hourHeightModifier: number = (hourSegments * segmentHeight) / MINUTES_IN_HOUR;

      let top: number = 0;

      if (eventStart > startOfView) {
        top += dateFns.differenceInMinutes(eventStart, startOfView);
      }

      top *= hourHeightModifier;

      const startDate: Date = startsBeforeDay ? startOfView : eventStart;
      const endDate: Date = endsAfterDay ? endOfView : eventEnd;

      let height: number = dateFns.differenceInMinutes(endDate, startDate);

      if (!event.end) {
        height = segmentHeight;
      } else {
        height *= hourHeightModifier;
      }

      const bottom: number = top + height;

      const overlappingPreviousEvents: DayViewEvent[] = previousDayEvents.filter((previousEvent: DayViewEvent) => {
        const previousEventTop: number = previousEvent.top;
        const previousEventBottom: number = previousEvent.top + previousEvent.height;

        if (top < previousEventBottom && previousEventBottom < bottom) {
          return true;
        } else if (previousEventTop <= top && bottom <= previousEventBottom) {
          return true;
        }

        return false;
      });

      let left: number = 0;

      while (overlappingPreviousEvents.some((previousEvent) => previousEvent.left === left)) {
        left += eventWidth;
      }

      const dayEvent: DayViewEvent = {
        event,
        height,
        width: eventWidth,
        top,
        left,
        startsBeforeDay,
        endsAfterDay,
      };

      if (height > 0) {
        previousDayEvents.push(dayEvent);
      }

      return dayEvent;
    })
    .filter((dayEvent: DayViewEvent) => dayEvent.height > 0);

  const width: number = Math.max(...dayViewEvents.map((event: DayViewEvent) => event.left + event.width));
  const allDayEvents: CalendarEvent[] = getEventsInPeriod({
    events: events.filter((event: CalendarEvent) => event.allDay),
    periodStart: dateFns.startOfDay(startOfView),
    periodEnd: dateFns.endOfDay(endOfView),
  });

  return {
    events: dayViewEvents,
    width,
    allDayEvents,
//.........这里部分代码省略.........
开发者ID:bullhorn,项目名称:novo-elements,代码行数:101,代码来源:CalendarUtils.ts


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