本文整理汇总了TypeScript中date-fns.startOfMinute函数的典型用法代码示例。如果您正苦于以下问题:TypeScript startOfMinute函数的具体用法?TypeScript startOfMinute怎么用?TypeScript startOfMinute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了startOfMinute函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
}).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;
});
示例2: 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;
}
示例3:
return events.filter((event) => {
const eventStart: Date = event.start;
const eventEnd: Date = event.end || eventStart;
const startOfView: Date = dateFns.setMinutes(dateFns.setHours(dateFns.startOfDay(eventStart), dayStart.hour), dayStart.minute);
const endOfView: Date = dateFns.setMinutes(dateFns.setHours(dateFns.startOfMinute(eventStart), dayEnd.hour), dayEnd.minute);
return dateFns.isAfter(eventEnd, startOfView) && dateFns.isBefore(eventStart, endOfView);
});
示例4: async
async(inject([MatDialog, MatDialogRef], (dialogSpy: MatDialog, dialogRef: MatDialogRef<any>) => {
const now = new Date();
const startTime = format(getTime(startOfMinute(now)), 'HH:mm');
const endTime = format(getTime(addHours(startOfMinute(now), 1)), 'HH:mm');
const lesson: Lesson = {
id: 0,
date: now,
startTime: startTime,
endTime: endTime,
lessonAttendees: [],
status: 'active'
};
component.addLesson(now);
expect(dialogSpy.open).toHaveBeenCalledWith(LessonEditorComponent, {
autoFocus: false,
data: lesson
});
dialogRef.afterClosed().subscribe((result) => expect(result).toBeTruthy());
dialogRef.close(lesson);
})));
示例5: 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,
//.........这里部分代码省略.........