Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
await apendFile('testUploads/' + filename, lor);
const execString = `touch -a -m -t ${randomDate} testUploads/${filename}`;
execCommands.push(execString);
}
// execute the modification command
for (const i of execCommands) {
await exec(i);
}
const files = await readDirAsync(uploadsPath());
for (const file of files) {
const fileStats = getFileStats(file);
const diff = differenceInDays(new Date(), fileStats.date);
if (diff > fileStats.retention) {
await deleteAsync(uploadsPath(fileStats.file));
console.log(
`Deleting ${fileStats.file} as ${diff} > ${
fileStats.retention
} created at ${format(fileStats.date, 'DD MMM YYYY')} Size: ${
fileStats.size
}`
);
}
}
// Delete generated test files
// fs.rmdirSync("testUploads"); => node can't delete folder that's not empty?
exec('rm -rf testUploads/');
}
weeks[weekStr] = startDays;
}
weeks[weekStr].push(dateWithModifiers);
lastWeekStr = weekStr;
}
var lastWeek = weeks[lastWeekStr];
var lastDay = lastWeek[lastWeek.length - 1];
var endDays = getOutsideEndDays(lastDay, props);
weeks[lastWeekStr] = lastWeek.concat(endDays);
// add extra weeks to the month, up to 6 weeks
if (fixedWeeks) {
lastWeek = weeks[lastWeekStr];
var lastWeekDate = lastWeek[lastWeek.length - 1].date;
var weeksInMonth = dateFns.getWeeksInMonth(month, { locale: locale });
if (weeksInMonth < 6) {
var diff_1 = dateFns.differenceInDays(dateFns.addWeeks(lastWeekDate, 6 - weeksInMonth), lastWeekDate);
for (var i = 0; i < diff_1; i++) {
var date = dateFns.addDays(lastWeekDate, i + 1);
var dateWithModifiers = new DateWithModifiers(date, { outside: 'end' }, props);
var week = dateFns.getWeek(date, { locale: locale });
if (week === 1 && dateFns.getMonth(month) === 11) {
week = 53;
}
if (!weeks[week]) {
weeks[week] = [];
}
weeks[week.toString()].push(dateWithModifiers);
}
}
}
return weeks;
}
_renderDays() {
// first day of current month view
const start = dateFns.startOfWeek(dateFns.startOfMonth(this._visibleDate));
// last day of current month view
const end = dateFns.endOfWeek(dateFns.endOfMonth(this._visibleDate));
// get all days and whether they are within the current month and range
const days = new Array(dateFns.differenceInDays(end, start) + 1)
.fill(start)
.map((s, i) => {
const theDate = dateFns.startOfDay(dateFns.addDays(s, i + this.options.weekStart));
const isThisMonth = dateFns.isSameMonth(this._visibleDate, theDate);
const isInRange = this.options.isRange && dateFns.isWithinRange(theDate, dateFns.startOfDay(this.start), dateFns.endOfDay(this.end));
let isDisabled = this.max ? dateFns.isAfter(dateFns.startOfDay(theDate), dateFns.endOfDay(this.max)) : false;
isDisabled = !isDisabled && this.min ? dateFns.isBefore(dateFns.startOfDay(theDate), dateFns.startOfDay(this.min)) : isDisabled;
if (this.disabledDates) {
for (let j = 0; j < this.disabledDates.length; j++) {
let day = this.disabledDates[j];
if (type.isFunction(day)) {
day = day(this);
}
if (dateFns.getTime(theDate) == dateFns.getTime(day)) {
isDisabled = true;
(cells: Cell[], events: DisplayedEvent[], firstCellDate: Date): Cell[] => {
for (const event of events) {
const firstCell = cells[Math.abs(differenceInDays(event.startDate, firstCellDate))]
let row = 0
let rows = []
firstCell.rows.sort((a, b) => a.row - b.row)
for (const cellRow of firstCell.rows) {
rows = [...rows, cellRow.row]
}
for (let i = 0; i <= Math.max(...rows) + 1; i++) {
if (!rows.includes(i)) {
row = i
break
}
}
let isPlaceholder = false
for (const day of eachDayOfInterval({start: event.startDate, end: event.endDate})) {
const cell = cells[Math.abs(differenceInDays(day, firstCellDate))]
let rowObject: CellRow = { row }
return modifiers.some(function (modifier) {
if (!modifier) {
return false;
}
if (modifier instanceof Date) {
return isSameDay(day, modifier);
}
if ('after' in modifier &&
'before' in modifier &&
differenceInDays(modifier.before, modifier.after) > 0) {
return (isDayAfter(day, modifier.after) && isDayBefore(day, modifier.before));
}
if ('after' in modifier &&
'before' in modifier &&
(isDayAfter(modifier.after, modifier.before) ||
isSameDay(modifier.after, modifier.before))) {
return (isDayAfter(day, modifier.after) || isDayBefore(day, modifier.before));
}
if ('after' in modifier) {
return isDayAfter(day, modifier.after);
}
if ('before' in modifier) {
return isDayBefore(day, modifier.before);
}
if ('daysOfWeek' in modifier) {
return modifier.daysOfWeek.includes(day.getDay());
private _eventLenght(item: DisplayedEvent): number {
return Math.abs(differenceInDays(item.startDate, item.endDate)) + 1
}
firstCell.rows.sort((a, b) => a.row - b.row)
for (const cellRow of firstCell.rows) {
rows = [...rows, cellRow.row]
}
for (let i = 0; i <= Math.max(...rows) + 1; i++) {
if (!rows.includes(i)) {
row = i
break
}
}
let isPlaceholder = false
for (const day of eachDayOfInterval({start: event.startDate, end: event.endDate})) {
const cell = cells[Math.abs(differenceInDays(day, firstCellDate))]
let rowObject: CellRow = { row }
if (!isPlaceholder) {
const eventLength = Math.abs(differenceInDays(event.startDate, event.endDate))
const formatedEventLength = `calc(${eventLength + 1}00% - 4px + ${eventLength}px`
const top = row * 24
rowObject = {
...rowObject,
placeholder: false,
event: {
title: event.title,
color: event.color,
id: 1,
width: formatedEventLength,
top
}
}
} else {
rowObject = {
...rowObject,
function getOutsideEndDays(day, props) {
var locale = props.locale;
var days = [];
var lastDayOfWeek = endOfWeek(day.date, { locale: locale });
var endDiff = differenceInDays(lastDayOfWeek, day.date);
for (var i = 1; i <= endDiff; i++) {
var dayDate = addDays(day.date, i);
var hidden = props.toMonth && dayDate > props.toMonth;
var modifiers = { outside: 'end', hidden: hidden };
var dateWithModifiers = new DateWithModifiers(dayDate, modifiers, props);
days.push(dateWithModifiers);
}
return days;
}
function isDayAfter(day1: Date, day2: Date): boolean {
return differenceInDays(day1, day2) > 0;
}
const firstCell = cells[Math.abs(differenceInDays(event.startDate, firstCellDate))]
let row = 0
let rows = []
firstCell.rows.sort((a, b) => a.row - b.row)
for (const cellRow of firstCell.rows) {
rows = [...rows, cellRow.row]
}
for (let i = 0; i <= Math.max(...rows) + 1; i++) {
if (!rows.includes(i)) {
row = i
break
}
}
let isPlaceholder = false
for (const day of eachDayOfInterval({start: event.startDate, end: event.endDate})) {
const cell = cells[Math.abs(differenceInDays(day, firstCellDate))]
let rowObject: CellRow = { row }
if (!isPlaceholder) {
const eventLength = Math.abs(differenceInDays(event.startDate, event.endDate))
const formatedEventLength = `calc(${eventLength + 1}00% - 4px + ${eventLength}px`
const top = row * 24
rowObject = {
...rowObject,
placeholder: false,
event: {
title: event.title,
color: event.color,
id: 1,
width: formatedEventLength,
top
}
}