asv-hlps 1.3.23 → 1.3.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/helpers/hlpProduct.js +1 -2
- package/lib/cjs/pdfs/invoices/infoInvoice.js +2 -3
- package/lib/cjs/pdfs/tools/tools.js +2 -2
- package/lib/cjs/sale.js +1 -1
- package/lib/cjs/utils.d.ts +1 -12
- package/lib/cjs/utils.js +57 -69
- package/lib/esm/helpers/hlpProduct.js +2 -3
- package/lib/esm/pdfs/invoices/infoInvoice.js +3 -4
- package/lib/esm/pdfs/tools/tools.js +3 -3
- package/lib/esm/sale.js +2 -2
- package/lib/esm/utils.d.ts +1 -12
- package/lib/esm/utils.js +55 -56
- package/package.json +1 -1
|
@@ -119,8 +119,7 @@ class HlpProduct {
|
|
|
119
119
|
let lots = [];
|
|
120
120
|
for (const pdtIn of ins) {
|
|
121
121
|
if (pdtIn.lot) {
|
|
122
|
-
|
|
123
|
-
lots.push(pdtIn.lot + " =>" + (0, utils_1.convertEnDateToFr)(pdtIn.expirationDate, "/"));
|
|
122
|
+
lots.push(pdtIn.lot + " =>" + (0, utils_1.dateFormatter)(pdtIn.expirationDate, "dmy", "/"));
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
125
|
return [...new Set(lots)];
|
|
@@ -27,8 +27,7 @@ const infoSale = (tob) => {
|
|
|
27
27
|
],
|
|
28
28
|
[
|
|
29
29
|
{ text: tob.ref, style: "rowText" },
|
|
30
|
-
|
|
31
|
-
{ text: (0, utils_1.convertEnDateToFr)(tob.createdAt, "/"), style: "rowText" },
|
|
30
|
+
{ text: (0, utils_1.dateFormatter)(tob.createdAt, "dmy", "/"), style: "rowText" },
|
|
32
31
|
{ text: nbProducts, style: "rowText" },
|
|
33
32
|
{ text: totalQtity, style: "rowText" },
|
|
34
33
|
{ text: nbColis, style: "rowText" },
|
|
@@ -66,7 +65,7 @@ const infoBill = (tob) => {
|
|
|
66
65
|
[
|
|
67
66
|
{ text: tob.ref, style: "rowText" },
|
|
68
67
|
// { text: moment(tob.createdAt ).format('DD/MM/YYYY'), style: 'rowText'},
|
|
69
|
-
{ text: (0, utils_1.
|
|
68
|
+
{ text: (0, utils_1.dateFormatter)(tob.createdAt, "dmy", "/"), style: "rowText" },
|
|
70
69
|
{ text: nbProducts, style: "rowText" },
|
|
71
70
|
{ text: totalQtity, style: "rowText" },
|
|
72
71
|
{ text: nbColis, style: "rowText" },
|
|
@@ -4,9 +4,9 @@ exports.displayClient = exports.displayTitle = exports.displayPdfDate = void 0;
|
|
|
4
4
|
const user_1 = require("../../user");
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
6
|
const displayPdfDate = (label, fromDate, toDate) => {
|
|
7
|
-
fromDate = !fromDate ? (0, utils_1.
|
|
7
|
+
fromDate = !fromDate ? (0, utils_1.dateFormatter)(new Date(), "ymd", "-") : fromDate;
|
|
8
8
|
toDate = !toDate ? fromDate : toDate;
|
|
9
|
-
return label + " du " + (0, utils_1.
|
|
9
|
+
return label + " du " + (0, utils_1.dateFormatter)(fromDate) + " au " + (0, utils_1.dateFormatter)(toDate);
|
|
10
10
|
};
|
|
11
11
|
exports.displayPdfDate = displayPdfDate;
|
|
12
12
|
const displayTitle = (title) => {
|
package/lib/cjs/sale.js
CHANGED
|
@@ -111,7 +111,7 @@ const tabLabel = (sale) => {
|
|
|
111
111
|
const name = (0, user_1.labelSteName)(sale.client.ste);
|
|
112
112
|
const product = sp.product.designation;
|
|
113
113
|
const pp = (0, utils_1.formatToStringCfa)(Math.ceil(sp.publicPrice));
|
|
114
|
-
const saleDate = (0, utils_1.
|
|
114
|
+
const saleDate = (0, utils_1.dateFormatter)(sale.saleDate, "dmy", "/");
|
|
115
115
|
// const saleDate = formatDateYmd(sale.saleDate, '/');
|
|
116
116
|
// const saleDate = moment(sale.saleDate ).format('DD/MM/YYYY');
|
|
117
117
|
labels.push({ name, product, pp, saleDate });
|
package/lib/cjs/utils.d.ts
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
import "dayjs/locale/fr";
|
|
2
|
-
export declare const formatDateYmdHypen: (date: Date | any) => string;
|
|
3
|
-
export declare const formatDateYmdHypenFr: (date: Date | any) => string;
|
|
4
|
-
export declare const formatDateFirstDayFr: (date: Date | any) => string;
|
|
5
|
-
export declare const formatDateYmHypen: (date: Date | any) => string;
|
|
6
|
-
export declare const formatFromAndToDate: (fromDate: Date, toDate: Date) => string;
|
|
7
|
-
export declare const formatDateYmd: (date: Date | any, separator?: string) => string;
|
|
8
|
-
export declare const formatDateYmFirstDay: (date: Date | any, separator?: string) => string;
|
|
9
|
-
export declare const formatDateYm: (date: Date | any, separator?: string) => string;
|
|
10
|
-
export declare const formatDateMd: (date: Date | any, separator?: string) => string;
|
|
11
|
-
export declare const convertEnDateToFr: (date: Date | any, separator?: string) => string;
|
|
12
|
-
export declare const convertFrDateToEnDate: (date: Date | any, separator?: string) => string;
|
|
13
2
|
export declare const genDateMinutesStep: (step: number, lang?: string) => string[];
|
|
14
3
|
export declare const percentOf: (nbr: number, percentage: number) => number;
|
|
15
4
|
export declare const calPercent: (nbr: number, percentage: number) => number;
|
|
@@ -99,7 +88,7 @@ export declare const returnBool: (tob?: boolean) => boolean;
|
|
|
99
88
|
export declare const monthStringName: (date: string | Date, format?: "MMM" | "MMMM", options?: {
|
|
100
89
|
en?: true;
|
|
101
90
|
}) => string;
|
|
102
|
-
export declare const dateFormatter: (date: Date | string, format?: "y" | "ymd" | "dmy" | "ago" | "dmy-hm" | "dmyfr" | "myfr" | "mfr-short" | "mfr-long", separator?: "/" | "-") => string;
|
|
91
|
+
export declare const dateFormatter: (date: Date | string, format?: "y" | "ymd" | "dmy" | "ago" | "md" | "dmy-hm" | "dmyfr" | "myfr" | "mfr-short" | "mfr-long", separator?: "/" | "" | "-") => string;
|
|
103
92
|
export declare const countryIsoToFlag: (code: string) => string;
|
|
104
93
|
export declare const removeParamKeyName: (params: any, name?: string) => any;
|
|
105
94
|
export declare const toggleProp: (tob: any, propToToggle: string) => any;
|
package/lib/cjs/utils.js
CHANGED
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.toggleProp = exports.removeParamKeyName = exports.countryIsoToFlag = exports.dateFormatter = exports.monthStringName = exports.returnBool = exports.formatAmountToString = exports.reduceSum = exports.sumAmount = exports.fillEndWithZero = exports.fillStartWithZero = exports.absFromSequence = exports.returnDates = exports.displayFrDatePeriode = exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor =
|
|
6
|
+
exports.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.formatMonthYearToLocaleString = exports.calculPercent = exports.validEmail = exports.convertToCfa = exports.packAndUnit = exports.unCheckedAll = exports.inputChecked = exports.arrayMultiChecked = exports.getPeriodDateColor = exports.getColorAccordingToDate = exports.genRandomColour = exports.formatNgbDate = exports.dateToString = exports.replaceSpacesWith = exports.replaceAllIn = exports.sesStorageGet = exports.sesStorageSet = exports.genSequenceRef = exports.removeBackSlashOccurences = exports.removeString = exports.deepClone = exports.findFirstSequenceMissing = exports.fillNumWithZero = exports.findSequencesMissing = exports.sequencesToNumbers = exports.notInSequence = exports.reformatDates = exports.currencyFormatterCfa = exports.formatToStringCfa = exports.currencyFormatter = exports.formatToString = exports.wakeUp = exports.sleep = exports.limitTo = exports.titleCase = exports.toObjectDate = exports.duplicateObjects = exports.removeDuplicateObjects = exports.getRandomColor = exports.getNbOfDaysBetweenTwoDates = exports.displayDateRangeFr = exports.calPercent = exports.percentOf = exports.genDateMinutesStep = void 0;
|
|
7
|
+
exports.toggleProp = exports.removeParamKeyName = exports.countryIsoToFlag = exports.dateFormatter = exports.monthStringName = exports.returnBool = exports.formatAmountToString = exports.reduceSum = exports.sumAmount = exports.fillEndWithZero = exports.fillStartWithZero = exports.absFromSequence = exports.returnDates = exports.displayFrDatePeriode = exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = void 0;
|
|
8
8
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
9
9
|
const relativeTime_1 = __importDefault(require("dayjs/plugin/relativeTime"));
|
|
10
10
|
const lodash_1 = __importDefault(require("lodash"));
|
|
@@ -14,69 +14,55 @@ dayjs_1.default.extend(relativeTime_1.default);
|
|
|
14
14
|
/* start: dates -------------------------------------- */
|
|
15
15
|
const name = () => { };
|
|
16
16
|
/* end: dates ---------------------------------------- */
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
exports.convertEnDateToFr = convertEnDateToFr;
|
|
68
|
-
const convertFrDateToEnDate = (date, separator = "-") => {
|
|
69
|
-
if (!date) {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
date = date.trim();
|
|
73
|
-
const day = date.substring(0, 2);
|
|
74
|
-
const month = date.substring(3, 5);
|
|
75
|
-
const year = date.substring(6, 10);
|
|
76
|
-
// return day + separator + month + separator + year
|
|
77
|
-
return year + separator + month + separator + day;
|
|
78
|
-
};
|
|
79
|
-
exports.convertFrDateToEnDate = convertFrDateToEnDate;
|
|
17
|
+
/* export const formatDateYmdHypenFr = (date: Date | any) => {
|
|
18
|
+
return convertEnDateToFr(formatDateYmd(date, "-"));
|
|
19
|
+
}; */
|
|
20
|
+
/* export const formatDateFirstDayFr = (date: Date | any) => {
|
|
21
|
+
return ("0" + 1).slice(-2) + "-" + ("0" + (date.getMonth() + 1)).slice(-2) + "-" + date.getUTCFullYear();
|
|
22
|
+
}; */
|
|
23
|
+
/* export const formatDateYmHypen = (date: Date | any) => {
|
|
24
|
+
return formatDateYm(date, "-");
|
|
25
|
+
}; */
|
|
26
|
+
/* export const formatFromAndToDate = (fromDate: Date, toDate: Date) => {
|
|
27
|
+
const getFromDate = !fromDate ? new Date() : fromDate;
|
|
28
|
+
const getToDate = !toDate ? fromDate : toDate;
|
|
29
|
+
return formatDateYmdHypenFr(new Date(getFromDate)) + " au " + formatDateYmdHypenFr(new Date(getToDate));
|
|
30
|
+
}; */
|
|
31
|
+
/* export const formatDateYmd = (date: Date | any, separator: string = "") => {
|
|
32
|
+
return formatDateYm(date, separator) + separator + ("0" + date.getUTCDate()).slice(-2);
|
|
33
|
+
}; */
|
|
34
|
+
/* export const formatDateYmFirstDay = (date: Date | any, separator: string = "") => {
|
|
35
|
+
return formatDateYm(date, separator) + separator + ("0" + 1).slice(-2);
|
|
36
|
+
}; */
|
|
37
|
+
/* export const formatDateYm = (date: Date | any, separator: string = "") => {
|
|
38
|
+
return date.getUTCFullYear() + separator + ("0" + (date.getMonth() + 1)).slice(-2);
|
|
39
|
+
}; */
|
|
40
|
+
/* export const formatDateMd = (date: Date | any, separator: string = "") => {
|
|
41
|
+
// return ('0' + (date.getMonth() + 1)).slice(-2) + separator + ('0' + date.getUTCDate()).slice(-2);
|
|
42
|
+
return date.getMonth() + 1 + separator + date.getUTCDate();
|
|
43
|
+
}; */
|
|
44
|
+
/* export const convertEnDateToFr = (date: Date | any, separator: string = "-") => {
|
|
45
|
+
if (!date) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
date = new Date(date).toISOString();
|
|
49
|
+
date = date.trim();
|
|
50
|
+
const year = date.substring(0, 4);
|
|
51
|
+
const month = date.substring(5, 7);
|
|
52
|
+
const day = date.substring(8, 10);
|
|
53
|
+
return day + separator + month + separator + year;
|
|
54
|
+
}; */
|
|
55
|
+
/* export const convertFrDateToEnDate = (date: Date | any, separator: string = "-") => {
|
|
56
|
+
if (!date) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
date = date.trim();
|
|
60
|
+
const day = date.substring(0, 2);
|
|
61
|
+
const month = date.substring(3, 5);
|
|
62
|
+
const year = date.substring(6, 10);
|
|
63
|
+
// return day + separator + month + separator + year
|
|
64
|
+
return year + separator + month + separator + day;
|
|
65
|
+
}; */
|
|
80
66
|
const genDateMinutesStep = (step, lang = "fr-FR") => {
|
|
81
67
|
const date = new Date(2021, 0, 1);
|
|
82
68
|
const series = [];
|
|
@@ -104,7 +90,7 @@ exports.calPercent = calPercent;
|
|
|
104
90
|
const displayDateRangeFr = (getFromDate, getToDate) => {
|
|
105
91
|
const fromDate = !getFromDate ? new Date() : getFromDate;
|
|
106
92
|
const toDate = !getToDate ? fromDate : getToDate;
|
|
107
|
-
return (0, exports.
|
|
93
|
+
return (0, exports.dateFormatter)(new Date(fromDate), "dmy", "/") + " au " + (0, exports.dateFormatter)(new Date(toDate), "dmy", "/");
|
|
108
94
|
};
|
|
109
95
|
exports.displayDateRangeFr = displayDateRangeFr;
|
|
110
96
|
const getNbOfDaysBetweenTwoDates = (date1, date2) => {
|
|
@@ -495,8 +481,8 @@ const padEndWithZero = (num, targetLength) => {
|
|
|
495
481
|
exports.padEndWithZero = padEndWithZero;
|
|
496
482
|
const isBirthday = (birthDayDate) => {
|
|
497
483
|
if (birthDayDate) {
|
|
498
|
-
const toDay = (0, exports.
|
|
499
|
-
const birthDay = (0, exports.
|
|
484
|
+
const toDay = (0, exports.dateFormatter)(new Date(), "md", "-");
|
|
485
|
+
const birthDay = (0, exports.dateFormatter)(new Date(birthDayDate), "md", "-");
|
|
500
486
|
return toDay === birthDay;
|
|
501
487
|
}
|
|
502
488
|
};
|
|
@@ -559,7 +545,7 @@ exports.getArrayOfRandomColor = getArrayOfRandomColor;
|
|
|
559
545
|
const displayFrDatePeriode = (getFromDate, getToDate) => {
|
|
560
546
|
const fromDate = !getFromDate ? new Date() : getFromDate;
|
|
561
547
|
const toDate = !getToDate ? fromDate : getToDate;
|
|
562
|
-
return (0, exports.
|
|
548
|
+
return (0, exports.dateFormatter)(new Date(fromDate), "dmy", "/") + " au " + (0, exports.dateFormatter)(new Date(toDate), "dmy", "/");
|
|
563
549
|
};
|
|
564
550
|
exports.displayFrDatePeriode = displayFrDatePeriode;
|
|
565
551
|
const returnDates = (fromDate, toDate) => {
|
|
@@ -635,6 +621,8 @@ const dateFormatter = (date, format = "dmy", separator = "/") => {
|
|
|
635
621
|
return (0, dayjs_1.default)(date).format("YYYY");
|
|
636
622
|
case "ymd":
|
|
637
623
|
return (0, dayjs_1.default)(date).format(`YYYY${separator}MM${separator}DD`);
|
|
624
|
+
case "md":
|
|
625
|
+
return (0, dayjs_1.default)(date).format(`MM${separator}DD`);
|
|
638
626
|
case "dmy":
|
|
639
627
|
return (0, dayjs_1.default)(date).format(`DD${separator}MM${separator}YYYY`);
|
|
640
628
|
case "dmy-hm":
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dateFormatter } from "../utils";
|
|
2
2
|
class HlpProduct {
|
|
3
3
|
productCatCode(product, catCodes) {
|
|
4
4
|
return catCodes.includes(product.cat.code && product.cat.code.toLowerCase());
|
|
@@ -117,8 +117,7 @@ class HlpProduct {
|
|
|
117
117
|
let lots = [];
|
|
118
118
|
for (const pdtIn of ins) {
|
|
119
119
|
if (pdtIn.lot) {
|
|
120
|
-
|
|
121
|
-
lots.push(pdtIn.lot + " =>" + convertEnDateToFr(pdtIn.expirationDate, "/"));
|
|
120
|
+
lots.push(pdtIn.lot + " =>" + dateFormatter(pdtIn.expirationDate, "dmy", "/"));
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
123
|
return [...new Set(lots)];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getNbFreezeOnBill, getNbPackagesOnBill, getNbProductsOnBill, getTotalQtityOnBill } from "../../bill";
|
|
2
2
|
import { getNbProductsOnSale, getTotalQtityOnSale } from "../../sale";
|
|
3
|
-
import {
|
|
3
|
+
import { dateFormatter } from "../../utils";
|
|
4
4
|
export const infoSale = (tob) => {
|
|
5
5
|
const totalQtity = getTotalQtityOnSale(tob);
|
|
6
6
|
const nbProducts = getNbProductsOnSale(tob);
|
|
@@ -24,8 +24,7 @@ export const infoSale = (tob) => {
|
|
|
24
24
|
],
|
|
25
25
|
[
|
|
26
26
|
{ text: tob.ref, style: "rowText" },
|
|
27
|
-
|
|
28
|
-
{ text: convertEnDateToFr(tob.createdAt, "/"), style: "rowText" },
|
|
27
|
+
{ text: dateFormatter(tob.createdAt, "dmy", "/"), style: "rowText" },
|
|
29
28
|
{ text: nbProducts, style: "rowText" },
|
|
30
29
|
{ text: totalQtity, style: "rowText" },
|
|
31
30
|
{ text: nbColis, style: "rowText" },
|
|
@@ -62,7 +61,7 @@ export const infoBill = (tob) => {
|
|
|
62
61
|
[
|
|
63
62
|
{ text: tob.ref, style: "rowText" },
|
|
64
63
|
// { text: moment(tob.createdAt ).format('DD/MM/YYYY'), style: 'rowText'},
|
|
65
|
-
{ text:
|
|
64
|
+
{ text: dateFormatter(tob.createdAt, "dmy", "/"), style: "rowText" },
|
|
66
65
|
{ text: nbProducts, style: "rowText" },
|
|
67
66
|
{ text: totalQtity, style: "rowText" },
|
|
68
67
|
{ text: nbColis, style: "rowText" },
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getSteShortname } from "../../user";
|
|
2
|
-
import {
|
|
2
|
+
import { dateFormatter } from "../../utils";
|
|
3
3
|
export const displayPdfDate = (label, fromDate, toDate) => {
|
|
4
|
-
fromDate = !fromDate ?
|
|
4
|
+
fromDate = !fromDate ? dateFormatter(new Date(), "ymd", "-") : fromDate;
|
|
5
5
|
toDate = !toDate ? fromDate : toDate;
|
|
6
|
-
return label + " du " +
|
|
6
|
+
return label + " du " + dateFormatter(fromDate) + " au " + dateFormatter(toDate);
|
|
7
7
|
};
|
|
8
8
|
export const displayTitle = (title) => {
|
|
9
9
|
return {
|
package/lib/esm/sale.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { unitPriceByClientCat } from "./product";
|
|
2
2
|
import { labelSteName } from "./user";
|
|
3
|
-
import {
|
|
3
|
+
import { dateFormatter, formatToStringCfa, removeBackSlashOccurences } from "./utils";
|
|
4
4
|
export const getNbProductsOnSale = (sale) => {
|
|
5
5
|
return sale.saleProducts.length || 0;
|
|
6
6
|
};
|
|
@@ -92,7 +92,7 @@ export const tabLabel = (sale) => {
|
|
|
92
92
|
const name = labelSteName(sale.client.ste);
|
|
93
93
|
const product = sp.product.designation;
|
|
94
94
|
const pp = formatToStringCfa(Math.ceil(sp.publicPrice));
|
|
95
|
-
const saleDate =
|
|
95
|
+
const saleDate = dateFormatter(sale.saleDate, "dmy", "/");
|
|
96
96
|
// const saleDate = formatDateYmd(sale.saleDate, '/');
|
|
97
97
|
// const saleDate = moment(sale.saleDate ).format('DD/MM/YYYY');
|
|
98
98
|
labels.push({ name, product, pp, saleDate });
|
package/lib/esm/utils.d.ts
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
import "dayjs/locale/fr";
|
|
2
|
-
export declare const formatDateYmdHypen: (date: Date | any) => string;
|
|
3
|
-
export declare const formatDateYmdHypenFr: (date: Date | any) => string;
|
|
4
|
-
export declare const formatDateFirstDayFr: (date: Date | any) => string;
|
|
5
|
-
export declare const formatDateYmHypen: (date: Date | any) => string;
|
|
6
|
-
export declare const formatFromAndToDate: (fromDate: Date, toDate: Date) => string;
|
|
7
|
-
export declare const formatDateYmd: (date: Date | any, separator?: string) => string;
|
|
8
|
-
export declare const formatDateYmFirstDay: (date: Date | any, separator?: string) => string;
|
|
9
|
-
export declare const formatDateYm: (date: Date | any, separator?: string) => string;
|
|
10
|
-
export declare const formatDateMd: (date: Date | any, separator?: string) => string;
|
|
11
|
-
export declare const convertEnDateToFr: (date: Date | any, separator?: string) => string;
|
|
12
|
-
export declare const convertFrDateToEnDate: (date: Date | any, separator?: string) => string;
|
|
13
2
|
export declare const genDateMinutesStep: (step: number, lang?: string) => string[];
|
|
14
3
|
export declare const percentOf: (nbr: number, percentage: number) => number;
|
|
15
4
|
export declare const calPercent: (nbr: number, percentage: number) => number;
|
|
@@ -99,7 +88,7 @@ export declare const returnBool: (tob?: boolean) => boolean;
|
|
|
99
88
|
export declare const monthStringName: (date: string | Date, format?: "MMM" | "MMMM", options?: {
|
|
100
89
|
en?: true;
|
|
101
90
|
}) => string;
|
|
102
|
-
export declare const dateFormatter: (date: Date | string, format?: "y" | "ymd" | "dmy" | "ago" | "dmy-hm" | "dmyfr" | "myfr" | "mfr-short" | "mfr-long", separator?: "/" | "-") => string;
|
|
91
|
+
export declare const dateFormatter: (date: Date | string, format?: "y" | "ymd" | "dmy" | "ago" | "md" | "dmy-hm" | "dmyfr" | "myfr" | "mfr-short" | "mfr-long", separator?: "/" | "" | "-") => string;
|
|
103
92
|
export declare const countryIsoToFlag: (code: string) => string;
|
|
104
93
|
export declare const removeParamKeyName: (params: any, name?: string) => any;
|
|
105
94
|
export declare const toggleProp: (tob: any, propToToggle: string) => any;
|
package/lib/esm/utils.js
CHANGED
|
@@ -7,58 +7,55 @@ dayjs.extend(relativeTime);
|
|
|
7
7
|
/* start: dates -------------------------------------- */
|
|
8
8
|
const name = () => { };
|
|
9
9
|
/* end: dates ---------------------------------------- */
|
|
10
|
-
export const
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
export const
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
export const
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
export const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
export const
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
export const
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
export const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// return day + separator + month + separator + year
|
|
60
|
-
return year + separator + month + separator + day;
|
|
61
|
-
};
|
|
10
|
+
/* export const formatDateYmdHypenFr = (date: Date | any) => {
|
|
11
|
+
return convertEnDateToFr(formatDateYmd(date, "-"));
|
|
12
|
+
}; */
|
|
13
|
+
/* export const formatDateFirstDayFr = (date: Date | any) => {
|
|
14
|
+
return ("0" + 1).slice(-2) + "-" + ("0" + (date.getMonth() + 1)).slice(-2) + "-" + date.getUTCFullYear();
|
|
15
|
+
}; */
|
|
16
|
+
/* export const formatDateYmHypen = (date: Date | any) => {
|
|
17
|
+
return formatDateYm(date, "-");
|
|
18
|
+
}; */
|
|
19
|
+
/* export const formatFromAndToDate = (fromDate: Date, toDate: Date) => {
|
|
20
|
+
const getFromDate = !fromDate ? new Date() : fromDate;
|
|
21
|
+
const getToDate = !toDate ? fromDate : toDate;
|
|
22
|
+
return formatDateYmdHypenFr(new Date(getFromDate)) + " au " + formatDateYmdHypenFr(new Date(getToDate));
|
|
23
|
+
}; */
|
|
24
|
+
/* export const formatDateYmd = (date: Date | any, separator: string = "") => {
|
|
25
|
+
return formatDateYm(date, separator) + separator + ("0" + date.getUTCDate()).slice(-2);
|
|
26
|
+
}; */
|
|
27
|
+
/* export const formatDateYmFirstDay = (date: Date | any, separator: string = "") => {
|
|
28
|
+
return formatDateYm(date, separator) + separator + ("0" + 1).slice(-2);
|
|
29
|
+
}; */
|
|
30
|
+
/* export const formatDateYm = (date: Date | any, separator: string = "") => {
|
|
31
|
+
return date.getUTCFullYear() + separator + ("0" + (date.getMonth() + 1)).slice(-2);
|
|
32
|
+
}; */
|
|
33
|
+
/* export const formatDateMd = (date: Date | any, separator: string = "") => {
|
|
34
|
+
// return ('0' + (date.getMonth() + 1)).slice(-2) + separator + ('0' + date.getUTCDate()).slice(-2);
|
|
35
|
+
return date.getMonth() + 1 + separator + date.getUTCDate();
|
|
36
|
+
}; */
|
|
37
|
+
/* export const convertEnDateToFr = (date: Date | any, separator: string = "-") => {
|
|
38
|
+
if (!date) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
date = new Date(date).toISOString();
|
|
42
|
+
date = date.trim();
|
|
43
|
+
const year = date.substring(0, 4);
|
|
44
|
+
const month = date.substring(5, 7);
|
|
45
|
+
const day = date.substring(8, 10);
|
|
46
|
+
return day + separator + month + separator + year;
|
|
47
|
+
}; */
|
|
48
|
+
/* export const convertFrDateToEnDate = (date: Date | any, separator: string = "-") => {
|
|
49
|
+
if (!date) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
date = date.trim();
|
|
53
|
+
const day = date.substring(0, 2);
|
|
54
|
+
const month = date.substring(3, 5);
|
|
55
|
+
const year = date.substring(6, 10);
|
|
56
|
+
// return day + separator + month + separator + year
|
|
57
|
+
return year + separator + month + separator + day;
|
|
58
|
+
}; */
|
|
62
59
|
export const genDateMinutesStep = (step, lang = "fr-FR") => {
|
|
63
60
|
const date = new Date(2021, 0, 1);
|
|
64
61
|
const series = [];
|
|
@@ -83,7 +80,7 @@ export const calPercent = (nbr, percentage) => {
|
|
|
83
80
|
export const displayDateRangeFr = (getFromDate, getToDate) => {
|
|
84
81
|
const fromDate = !getFromDate ? new Date() : getFromDate;
|
|
85
82
|
const toDate = !getToDate ? fromDate : getToDate;
|
|
86
|
-
return
|
|
83
|
+
return dateFormatter(new Date(fromDate), "dmy", "/") + " au " + dateFormatter(new Date(toDate), "dmy", "/");
|
|
87
84
|
};
|
|
88
85
|
export const getNbOfDaysBetweenTwoDates = (date1, date2) => {
|
|
89
86
|
const day = 1000 * 60 * 60 * 24;
|
|
@@ -431,8 +428,8 @@ export const padEndWithZero = (num, targetLength) => {
|
|
|
431
428
|
};
|
|
432
429
|
export const isBirthday = (birthDayDate) => {
|
|
433
430
|
if (birthDayDate) {
|
|
434
|
-
const toDay =
|
|
435
|
-
const birthDay =
|
|
431
|
+
const toDay = dateFormatter(new Date(), "md", "-");
|
|
432
|
+
const birthDay = dateFormatter(new Date(birthDayDate), "md", "-");
|
|
436
433
|
return toDay === birthDay;
|
|
437
434
|
}
|
|
438
435
|
};
|
|
@@ -488,7 +485,7 @@ export const getArrayOfRandomColor = (length, type = "hex") => {
|
|
|
488
485
|
export const displayFrDatePeriode = (getFromDate, getToDate) => {
|
|
489
486
|
const fromDate = !getFromDate ? new Date() : getFromDate;
|
|
490
487
|
const toDate = !getToDate ? fromDate : getToDate;
|
|
491
|
-
return
|
|
488
|
+
return dateFormatter(new Date(fromDate), "dmy", "/") + " au " + dateFormatter(new Date(toDate), "dmy", "/");
|
|
492
489
|
};
|
|
493
490
|
export const returnDates = (fromDate, toDate) => {
|
|
494
491
|
if (fromDate === undefined || fromDate === null) {
|
|
@@ -554,6 +551,8 @@ export const dateFormatter = (date, format = "dmy", separator = "/") => {
|
|
|
554
551
|
return dayjs(date).format("YYYY");
|
|
555
552
|
case "ymd":
|
|
556
553
|
return dayjs(date).format(`YYYY${separator}MM${separator}DD`);
|
|
554
|
+
case "md":
|
|
555
|
+
return dayjs(date).format(`MM${separator}DD`);
|
|
557
556
|
case "dmy":
|
|
558
557
|
return dayjs(date).format(`DD${separator}MM${separator}YYYY`);
|
|
559
558
|
case "dmy-hm":
|