Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'calendar-utils' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
function getDayView(events, viewDate, dayViewStart, dayViewEnd, dayViewSplit, dayViewEventWidth, dayViewSegmentSize) {
var dayStart = (dayViewStart || '00:00').split(':');
var dayEnd = (dayViewEnd || '23:59').split(':');
var view = calendarUtils.getDayView({
events: events.map(function(event) { // hack required to work with event API
var eventPeriod = getRecurringEventPeriod({
start: moment(event.startsAt),
end: moment(event.endsAt || event.startsAt)
}, event.recursOn, moment(viewDate).startOf('day'));
return updateEventForCalendarUtils(event, eventPeriod);
}),
viewDate: viewDate,
hourSegments: 60 / dayViewSplit,
dayStart: {
hour: dayStart[0],
minute: dayStart[1]
},
dayEnd: {
hour: dayEnd[0],
minute: dayEnd[1]
function getMonthView(events, viewDate, cellModifier, excluded) {
// hack required to work with the calendar-utils api
events.forEach(function(event) {
var eventPeriod = getRecurringEventPeriod({
start: moment(event.startsAt),
end: moment(event.endsAt || event.startsAt)
}, event.recursOn, moment(viewDate).startOf('month'));
updateEventForCalendarUtils(event, eventPeriod);
});
var view = calendarUtils.getMonthView({
events: events,
viewDate: viewDate,
excluded: excluded,
weekStartsOn: moment().startOf('week').day()
});
view.days = view.days.map(function(day) {
day.date = moment(day.date);
day.label = day.date.date();
day.badgeTotal = getBadgeTotal(day.events);
if (!calendarConfig.displayAllMonthEvents && !day.inMonth) {
day.events = [];
}
cellModifier({calendarCell: day});
return day;
});
function updateDays() {
vm.dayViewSplit = parseInt(vm.dayViewSplit);
var dayStart = (vm.dayViewStart || '00:00').split(':');
var dayEnd = (vm.dayViewEnd || '23:59').split(':');
vm.hourGrid = calendarUtils.getDayViewHourGrid({
viewDate: vm.view === 'week' ? moment(vm.viewDate).startOf('week').toDate() : moment(vm.viewDate).toDate(),
hourSegments: 60 / vm.dayViewSplit,
dayStart: {
hour: dayStart[0],
minute: dayStart[1]
},
dayEnd: {
hour: dayEnd[0],
minute: dayEnd[1]
}
});
vm.hourGrid.forEach(function(hour) {
hour.segments.forEach(function(segment) {
segment.date = moment(segment.date);
export const validateEvents = (events: CalendarEvent[]) => {
const warn = (...args) => console.warn('angular-calendar', ...args);
return validateEventsWithoutLog(events, warn);
};
var days = calendarUtils.getWeekViewHeader({
viewDate: viewDate,
excluded: excluded,
weekStartsOn: moment().startOf('week').day()
}).map(function(day) {
day.date = moment(day.date);
day.weekDayLabel = formatDate(day.date, calendarConfig.dateFormats.weekDay);
day.dayLabel = formatDate(day.date, calendarConfig.dateFormats.day);
return day;
});
var startOfWeek = moment(viewDate).startOf('week');
var endOfWeek = moment(viewDate).endOf('week');
var eventRows = calendarUtils.getWeekView({
viewDate: viewDate,
weekStartsOn: moment().startOf('week').day(),
excluded: excluded,
events: filterEventsInPeriod(events, startOfWeek, endOfWeek).map(function(event) {
var weekViewStart = moment(startOfWeek).startOf('day');
var eventPeriod = getRecurringEventPeriod({
start: moment(event.startsAt),
end: moment(event.endsAt || event.startsAt)
}, event.recursOn, weekViewStart);
var calendarUtilsEvent = {
originalEvent: event,
start: eventPeriod.start.toDate()
};
row: newEvents.map(function(dayEvent) {
var event = dayEvent.event;
return {
event: event,
top: dayEvent.top,
offset: calendarUtils.getWeekViewEventOffset({
event: {
start: event.startsAt,
end: event.endsAt
},
startOfWeek: moment(viewDate).startOf('week').toDate()
})
};
})
}];
function getWeekView(events, viewDate, excluded) {
var days = calendarUtils.getWeekViewHeader({
viewDate: viewDate,
excluded: excluded,
weekStartsOn: moment().startOf('week').day()
}).map(function(day) {
day.date = moment(day.date);
day.weekDayLabel = formatDate(day.date, calendarConfig.dateFormats.weekDay);
day.dayLabel = formatDate(day.date, calendarConfig.dateFormats.day);
return day;
});
var startOfWeek = moment(viewDate).startOf('week');
var endOfWeek = moment(viewDate).endOf('week');
var eventRows = calendarUtils.getWeekView({
viewDate: viewDate,
weekStartsOn: moment().startOf('week').day(),
export function adapterFactory(): DateAdapter {
return {
...baseAdapterFactory(),
addWeeks,
addMonths,
subDays,
subWeeks,
subMonths,
getISOWeek,
setDate,
setMonth,
setYear,
getDate,
getYear
};
}
export function adapterFactory(moment): DateAdapter {
return {
...baseAdapterFactory(moment),
addWeeks(date: Date | number, amount: number): Date {
return moment(date)
.add(amount, 'weeks')
.toDate();
},
addMonths(date: Date | number, amount: number): Date {
return moment(date)
.add(amount, 'months')
.toDate();
},
subDays(date: Date | number, amount: number): Date {
return moment(date)
.subtract(amount, 'days')
)
.replace(
'\n<span class="hljs-keyword">import</span> { RouterModule } from <span class="hljs-string">\'@angular/router\'</span>;',
''
)
},
language: languages[extension]
};
});
}
const dependencyVersions: any = {
angular: require('@angular/core/package.json').version,
angularRouter: require('@angular/router/package.json').version,
angularCalendar: require('../../../package.json').version,
calendarUtils: require('calendar-utils/package.json').version,
angularResizableElement: require('angular-resizable-element/package.json')
.version,
angularDraggableDroppable: require('angular-draggable-droppable/package.json')
.version,
dateFns: require('date-fns/package.json').version,
rxjs: require('rxjs/package.json').version,
bootstrap: require('bootstrap-css-only/package.json').version,
zoneJs: require('zone.js/package.json').version,
ngBootstrap: require('@ng-bootstrap/ng-bootstrap/package.json').version,
rrule: require('rrule/package.json').version,
fontAwesome: require('font-awesome/package.json').version,
positioning: require('positioning/package.json').version,
flatpickr: require('flatpickr/package.json').version,
angularxFlatpickr: require('angularx-flatpickr/package.json').version
};