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:
@@ -1,7 +1,7 @@
|
||||
import { CalendarOutlined } from "@ant-design/icons";
|
||||
import { Card, Col, Divider, Row, Statistic } from "antd";
|
||||
import _ from "lodash";
|
||||
import moment from "moment";
|
||||
import dayjs from "../../utils/day";
|
||||
import React, { useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
@@ -35,7 +35,7 @@ export function ScoreboardTargetsTable({ bodyshop, scoreBoardlist }) {
|
||||
toDatePaint: 0,
|
||||
};
|
||||
|
||||
const today = moment();
|
||||
const today = dayjs();
|
||||
if (dateHash[today.format("YYYY-MM-DD")]) {
|
||||
dateHash[today.format("YYYY-MM-DD")].forEach((d) => {
|
||||
ret.todayBody = ret.todayBody + d.bodyhrs;
|
||||
@@ -43,7 +43,7 @@ export function ScoreboardTargetsTable({ bodyshop, scoreBoardlist }) {
|
||||
});
|
||||
}
|
||||
|
||||
let StartOfWeek = moment().startOf("week");
|
||||
let StartOfWeek = dayjs().startOf("week");
|
||||
while (StartOfWeek.isSameOrBefore(today)) {
|
||||
if (dateHash[StartOfWeek.format("YYYY-MM-DD")]) {
|
||||
dateHash[StartOfWeek.format("YYYY-MM-DD")].forEach((d) => {
|
||||
@@ -54,7 +54,7 @@ export function ScoreboardTargetsTable({ bodyshop, scoreBoardlist }) {
|
||||
StartOfWeek = StartOfWeek.add(1, "day");
|
||||
}
|
||||
|
||||
let startOfMonth = moment().startOf("month");
|
||||
let startOfMonth = dayjs().startOf("month");
|
||||
while (startOfMonth.isSameOrBefore(today)) {
|
||||
if (dateHash[startOfMonth.format("YYYY-MM-DD")]) {
|
||||
dateHash[startOfMonth.format("YYYY-MM-DD")].forEach((d) => {
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
import moment from "moment-business-days";
|
||||
import dayjs from "../../utils/day";
|
||||
|
||||
// moment.updateLocale("ca", {
|
||||
// dayjs.updateLocale("ca", {
|
||||
// workingWeekdays: [1, 2, 3, 4, 5, 6],
|
||||
// });
|
||||
|
||||
export const CalculateWorkingDaysThisMonth = () => {
|
||||
return moment().endOf("month").businessDaysIntoMonth();
|
||||
return dayjs().endOf("month").businessDaysInMonth();
|
||||
};
|
||||
|
||||
export const CalculateWorkingDaysInPeriod = (start, end) => {
|
||||
return moment(start).businessDiff(moment(end));
|
||||
return dayjs(start).businessDiff(dayjs(end));
|
||||
};
|
||||
|
||||
export const CalculateWorkingDaysAsOfToday = () => {
|
||||
return moment().businessDaysIntoMonth();
|
||||
return dayjs().businessDaysInMonth();
|
||||
};
|
||||
|
||||
export const CalculateWorkingDaysLastMonth = () => {
|
||||
return moment().subtract(1, "month").endOf("month").businessDaysIntoMonth();
|
||||
return dayjs().subtract(1, "month").endOf("month").businessDaysInMonth();
|
||||
};
|
||||
|
||||
export const WeeklyTargetHrs = (dailyTargetHrs, bodyshop) => {
|
||||
return (
|
||||
dailyTargetHrs *
|
||||
CalculateWorkingDaysInPeriod(
|
||||
moment().startOf("week"),
|
||||
moment().endOf("week")
|
||||
dayjs().startOf("week"),
|
||||
dayjs().endOf("week")
|
||||
)
|
||||
);
|
||||
};
|
||||
@@ -53,20 +53,22 @@ export const AsOfTodayTargetHrs = (dailyTargetHrs, bodyshop) => {
|
||||
|
||||
export const AsOfDateTargetHours = (dailyTargetHours, date) => {
|
||||
return (
|
||||
dailyTargetHours * moment().startOf("month").businessDiff(moment(date))
|
||||
dailyTargetHours * dayjs().startOf("month").businessDiff(dayjs(date))
|
||||
);
|
||||
};
|
||||
|
||||
export const ListOfBusinessDaysInCurrentMonth = () => {
|
||||
const momentListOfDays = moment().monthBusinessDays();
|
||||
// TODO This is probably broken :/
|
||||
console.log('Hit!!!!')
|
||||
const momentListOfDays = dayjs().businessDaysInMonth();
|
||||
|
||||
return momentListOfDays.map((i) => i.format("YYYY-MM-DD"));
|
||||
};
|
||||
|
||||
export const ListOfDaysInCurrentMonth = () => {
|
||||
const days = [];
|
||||
const dateStart = moment().startOf("month");
|
||||
const dateEnd = moment().endOf("month");
|
||||
const dateStart = dayjs().startOf("month");
|
||||
const dateEnd = dayjs().endOf("month");
|
||||
while (dateEnd.diff(dateStart, "days") > 0) {
|
||||
days.push(dateStart.format("YYYY-MM-DD"));
|
||||
dateStart.add(1, "days");
|
||||
@@ -77,8 +79,8 @@ export const ListOfDaysInCurrentMonth = () => {
|
||||
|
||||
export const ListDaysBetween = ({ start, end }) => {
|
||||
const days = [];
|
||||
const dateStart = moment(start);
|
||||
const dateEnd = moment(end);
|
||||
const dateStart = dayjs(start);
|
||||
const dateEnd = dayjs(end);
|
||||
while (dateEnd.diff(dateStart, "days") > 0) {
|
||||
days.push(dateStart.format("YYYY-MM-DD"));
|
||||
dateStart.add(1, "days");
|
||||
|
||||
Reference in New Issue
Block a user