本文整理汇总了TypeScript中date-fns.addMinutes函数的典型用法代码示例。如果您正苦于以下问题:TypeScript addMinutes函数的具体用法?TypeScript addMinutes怎么用?TypeScript addMinutes使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了addMinutes函数的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: 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 });
}
示例3: iCalEventForExam
export function iCalEventForExam(module: Module, semester: Semester): EventOption | null {
const semesterData = getModuleSemesterData(module, semester);
if (!semesterData) return null;
const { examDate, examDuration } = semesterData;
if (!examDate) return null;
const start = new Date(examDate);
if (!isValid(start)) return null;
return {
start,
end: addMinutes(start, examDuration || DEFAULT_EXAM_DURATION),
summary: `${module.moduleCode} Exam`,
description: module.title,
};
}
示例4: addLessonOffset
function addLessonOffset(date: Date, hourOffset: number): Date {
return addMinutes(date, hourOffset * 60);
}