本文整理汇总了TypeScript中date-fns.startOfDay函数的典型用法代码示例。如果您正苦于以下问题:TypeScript startOfDay函数的具体用法?TypeScript startOfDay怎么用?TypeScript startOfDay使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了startOfDay函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:MagicAardvark,项目名称:novo-elements,代码行数:30,代码来源:CalendarUtils.ts
示例2:
}).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:MagicAardvark,项目名称:novo-elements,代码行数:33,代码来源:CalendarUtils.ts
示例3: it
it('dayViewHour', () => {
expect(
dateFormatter.dayViewHour({
date: startOfDay(new Date('2016-01-01')),
locale: 'en'
})
).to.equal('12 AM');
});
开发者ID:Nolvafrell,项目名称:angular-calendar,代码行数:8,代码来源:calendar-native-date-formatter.provider.spec.ts
示例4:
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);
});
开发者ID:bullhorn,项目名称:novo-elements,代码行数:9,代码来源:CalendarUtils.ts
示例5: getWeekDay
function getWeekDay({ date }: { date: Date }): WeekDay {
const today: Date = dateFns.startOfDay(new Date());
return {
date,
isPast: date < today,
isToday: dateFns.isSameDay(date, today),
isFuture: date > today,
isWeekend: WEEKEND_DAY_NUMBERS.indexOf(dateFns.getDay(date)) > -1,
};
}
开发者ID:bullhorn,项目名称:novo-elements,代码行数:10,代码来源:CalendarUtils.ts
示例6: createSchedule
function createSchedule(props: Partial<Schedule> & {transaction_date: Date} = {transaction_date: new Date()}): Schedule & {transaction_date: Date} {
return Object.assign({
transaction_date: new Date(),
frequency: "Monthly" as ScheduleFrequency,
next_due_date: addDays(startOfDay(new Date()), 3),
auto_enter: false,
autoFlag: false,
overdue_count: 0,
estimate: false
}, props);
}
开发者ID:scottohara,项目名称:loot,代码行数:11,代码来源:index.ts
示例7: createPartialTransaction
function createPartialTransaction(props: Partial<Transaction | SplitTransactionChild>): Partial<Transaction | SplitTransactionChild> {
id++;
return Object.assign({
id,
memo: "",
flag: null,
balance: 0,
transaction_date: subDays(startOfDay(new Date()), 1),
status: "" as TransactionStatus
}, props);
}
开发者ID:scottohara,项目名称:loot,代码行数:12,代码来源:index.ts
示例8: 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
示例9: it
it('should set the view date to the start of today', () => {
const fixture: ComponentFixture<TestComponent> = TestBed.createComponent(
TestComponent
);
fixture.componentInstance.viewDate = new Date('2017-01-28');
fixture.detectChanges();
fixture.nativeElement.querySelector('button').click();
fixture.detectChanges();
expect(fixture.componentInstance.viewDate).to.deep.equal(
startOfDay(new Date())
);
fixture.destroy();
});
开发者ID:Nolvafrell,项目名称:angular-calendar,代码行数:13,代码来源:calendar-today.directive.spec.ts
示例10: 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
注:本文中的date-fns.startOfDay函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论