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,10 +1,10 @@
import { Tooltip } from "antd";
import moment from "moment";
import dayjs from "../utils/day";
import React from "react";
export function DateFormatter(props) {
return props.children
? moment(props.children).format(
? dayjs(props.children).format(
props.includeDay ? "ddd MM/DD/YYYY" : "MM/DD/YYYY"
)
: null;
@@ -12,19 +12,19 @@ export function DateFormatter(props) {
export function DateTimeFormatter(props) {
return props.children
? moment(props.children).format(
? dayjs(props.children).format(
props.format ? props.format : "MM/DD/YYYY hh:mm a"
)
: null;
}
export function TimeFormatter(props) {
return props.children
? moment(props.children).format(props.format ? props.format : "hh:mm a")
? dayjs(props.children).format(props.format ? props.format : "hh:mm a")
: null;
}
export function TimeAgoFormatter(props) {
const m = moment(props.children);
const m = dayjs(props.children);
return props.children ? (
<Tooltip placement="top" title={m.format("MM/DD/YYY hh:mm A")}>
{m.fromNow()}
@@ -33,5 +33,5 @@ export function TimeAgoFormatter(props) {
}
export function DateTimeFormat(value) {
return moment(value).format("MM/DD/YYYY hh:mm A");
return dayjs(value).format("MM/DD/YYYY hh:mm A");
}

View File

@@ -1,27 +1,27 @@
import moment from "moment";
import dayjs from "./day";
const range = {
Today: [moment(), moment()],
"Last 14 days": [moment().subtract(14, "days"), moment()],
"Last 7 days": [moment().subtract(7, "days"), moment()],
"Next 7 days": [moment(), moment().add(7, "days")],
"Next 14 days": [moment(), moment().add(14, "days")],
Today: [dayjs(), dayjs()],
"Last 14 days": [dayjs().subtract(14, "days"), dayjs()],
"Last 7 days": [dayjs().subtract(7, "days"), dayjs()],
"Next 7 days": [dayjs(), dayjs().add(7, "days")],
"Next 14 days": [dayjs(), dayjs().add(14, "days")],
"Last Month": [
moment().startOf("month").subtract(1, "month"),
moment().startOf("month").subtract(1, "month").endOf("month"),
dayjs().startOf("month").subtract(1, "month"),
dayjs().startOf("month").subtract(1, "month").endOf("month"),
],
"This Month": [moment().startOf("month"), moment().endOf("month")],
"This Month": [dayjs().startOf("month"), dayjs().endOf("month")],
"Next Month": [
moment().startOf("month").add(1, "month"),
moment().startOf("month").add(1, "month").endOf("month"),
dayjs().startOf("month").add(1, "month"),
dayjs().startOf("month").add(1, "month").endOf("month"),
],
"Last Quarter": [
moment().startOf("quarter").subtract(1, "quarters"),
moment().startOf("quarter").subtract(1, "day"),
dayjs().startOf("quarter").subtract(1, "quarters"),
dayjs().startOf("quarter").subtract(1, "day"),
],
"This Quarter": [
moment().startOf("quarter"),
moment().startOf("quarter").add(1, "quarter").subtract(1, "day"),
dayjs().startOf("quarter"),
dayjs().startOf("quarter").add(1, "quarter").subtract(1, "day"),
],
"Last 90 Days": [moment().add(-90, "days"), moment()],
"Last 90 Days": [dayjs().add(-90, "days"), dayjs()],
};
export default range;

View File

@@ -73,7 +73,7 @@ export default async function RenderTemplate(
headerpath: `/${bodyshop.imexshopid}/header.html`,
footerpath: `/${bodyshop.imexshopid}/footer.html`,
bodyshop: bodyshop,
offset: bodyshop.timezone, //moment().utcOffset(),
offset: bodyshop.timezone, //dayjs().utcOffset(),
},
};

15
client/src/utils/day.js Normal file
View File

@@ -0,0 +1,15 @@
import dayjs from 'dayjs';
import dayjsBusinessDays from "dayjs-business-days2";
import isSameOrAfter from "dayjs/plugin/isSameOrAfter";
import isSameOrBefore from "dayjs/plugin/isSameOrBefore";
import timezone from 'dayjs/plugin/timezone';
import utc from 'dayjs/plugin/utc';
dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.extend(dayjsBusinessDays);
dayjs.extend(isSameOrAfter);
dayjs.extend(isSameOrBefore);
export default dayjs;