本文整理汇总了TypeScript中date-fns.addHours函数的典型用法代码示例。如果您正苦于以下问题:TypeScript addHours函数的具体用法?TypeScript addHours怎么用?TypeScript addHours使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了addHours函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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;
}
示例2: inject
inject([LessonService], (lessonService) => {
const calendarEvent = component.events[0];
const newStart = parse(format(new Date(), 'YYYY-MM-DD'));
const newEnd = addHours(newStart, 1);
let refreshed = false;
component.refresh.subscribe(() => refreshed = true);
component.changeEventTimes({ event: calendarEvent, newStart: newStart, newEnd: newEnd, type: undefined });
expect(calendarEvent.start).toEqual(newStart);
expect(calendarEvent.end).toEqual(newEnd);
expect(refreshed).toBeTruthy();
expect(lessonService.updateLesson).toHaveBeenCalledWith(calendarEvent.meta);
}));
示例3: 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);
})));
示例4: isSameDay
.filter(showtime => showtime.playingAt && isSameDay(addHours(showtime.playingAt, -4), date));