This is a breaking change, moment is no longer with us, let us have a dayjs of silence.

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2023-12-13 19:06:15 -05:00
parent 25173b0903
commit 65157a094f
97 changed files with 772 additions and 592 deletions

View File

@@ -1,28 +1,28 @@
import moment from "moment";
import dayjs from "../../utils/day";
export function getRange(dateParam, viewParam) {
let start, end;
let date = dateParam || new Date();
let view = viewParam || "week";
// if view is day: from moment(date).startOf('day') to moment(date).endOf('day');
// if view is day: from dayjs(date).startOf('day') to dayjs(date).endOf('day');
if (view === "day") {
start = moment(date).startOf("day");
end = moment(date).endOf("day");
start = dayjs(date).startOf("day");
end = dayjs(date).endOf("day");
}
// if view is week: from moment(date).startOf('isoWeek') to moment(date).endOf('isoWeek');
// if view is week: from dayjs(date).startOf('isoWeek') to dayjs(date).endOf('isoWeek');
else if (view === "week") {
start = moment(date).startOf("week");
end = moment(date).endOf("week");
start = dayjs(date).startOf("week");
end = dayjs(date).endOf("week");
}
//if view is month: from moment(date).startOf('month').subtract(7, 'days') to moment(date).endOf('month').add(7, 'days'); i do additional 7 days math because you can see adjacent weeks on month view (that is the way how i generate my recurrent events for the Big Calendar, but if you need only start-end of month - just remove that math);
//if view is month: from dayjs(date).startOf('month').subtract(7, 'days') to dayjs(date).endOf('month').add(7, 'days'); i do additional 7 days math because you can see adjacent weeks on month view (that is the way how i generate my recurrent events for the Big Calendar, but if you need only start-end of month - just remove that math);
else if (view === "month") {
start = moment(date).startOf("month").subtract(7, "days");
end = moment(date).endOf("month").add(7, "days");
start = dayjs(date).startOf("month").subtract(7, "days");
end = dayjs(date).endOf("month").add(7, "days");
}
// if view is agenda: from moment(date).startOf('day') to moment(date).endOf('day').add(1, 'month');
// if view is agenda: from dayjs(date).startOf('day') to dayjs(date).endOf('day').add(1, 'month');
else if (view === "agenda") {
start = moment(date).startOf("day");
end = moment(date).endOf("day").add(1, "month");
start = dayjs(date).startOf("day");
end = dayjs(date).endOf("day").add(1, "month");
}
return { start, end };