asv-hlps 1.4.39 → 1.4.41
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/plans/models/CreditPlan.d.ts +11 -0
- package/lib/cjs/plans/models/CreditPlan.js +2 -0
- package/lib/cjs/utils.d.ts +6 -3
- package/lib/cjs/utils.js +42 -17
- package/lib/esm/plans/models/CreditPlan.d.ts +11 -0
- package/lib/esm/plans/models/CreditPlan.js +1 -0
- package/lib/esm/utils.d.ts +6 -3
- package/lib/esm/utils.js +36 -13
- package/package.json +6 -6
package/lib/cjs/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ConfigType, OpUnitType, QUnitType } from "dayjs";
|
|
2
|
+
import EDatePeriodicity from "./shared/models/EDatePeriodicity";
|
|
2
3
|
import "dayjs/locale/fr";
|
|
3
4
|
export declare const isEmpty: (str: string) => str is "";
|
|
4
5
|
export declare const formatDateFirstDayFr: (date: Date | any) => string;
|
|
@@ -45,8 +46,6 @@ export declare const toPlural: (word: string) => string;
|
|
|
45
46
|
export declare const replaceAllIn: (text: string, regex?: RegExp, toChar?: string) => string;
|
|
46
47
|
export declare const replaceSpacesWith: (text: string, toChar?: string) => string;
|
|
47
48
|
export declare const dateFormatter: (date: Date | string, format?: "y" | "ym" | "ymd" | "dmy" | "ago" | "md" | "dmy-hm" | "dmyfr" | "myfr" | "mfr-short" | "mfr-long", separator?: "/" | "" | "-") => string;
|
|
48
|
-
export declare const getNthWeek: (startDate: Date | string, endDate: Date | string, nthWeek: number) => dayjs.Dayjs;
|
|
49
|
-
export declare const dateNthWeek: (startDate: Date | string, endDate: Date | string, nthWeek: number) => number;
|
|
50
49
|
export declare const dateDiff: (date1: ConfigType, unit?: QUnitType | OpUnitType, date2?: Date) => number;
|
|
51
50
|
export declare const dateToString: (date: Date | any) => string;
|
|
52
51
|
export declare const firstDayOfDate: (date: Date | any) => string;
|
|
@@ -56,6 +55,10 @@ export declare const reformatDates: (fromDate: any, toDate: any) => {
|
|
|
56
55
|
};
|
|
57
56
|
export declare const displayDateRangeFr: (getFromDate?: any, getToDate?: any) => string;
|
|
58
57
|
export declare const getNbOfDaysBetweenTwoDates: (date1: Date, date2: Date) => number;
|
|
58
|
+
export declare const dateNthWeek: (startDate: any, endDate: any, nthWeek: number) => number;
|
|
59
|
+
export declare const dateNthDay: (startDate: any, endDate: any, nthday: number) => number;
|
|
60
|
+
export declare const dateNthMonth: (startDate: any, endDate: any, nthMonth: number) => number;
|
|
61
|
+
export declare const dateNth: (startDate: any, endDate: any, nth: number, periodicity: EDatePeriodicity) => number;
|
|
59
62
|
export declare const formatNgbDate: (date: any) => {
|
|
60
63
|
fromDate: string;
|
|
61
64
|
toDate: string;
|
package/lib/cjs/utils.js
CHANGED
|
@@ -3,16 +3,19 @@ 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.nthIndexOf = exports.pathName = exports.checkObjInArray = exports.arraySome = exports.winMaxHeight = exports.toggleProp = exports.roundLastNDigits = exports.removeParamKeyName = exports.countryIsoToFlag = exports.monthStringName = exports.returnBool = exports.formatAmountToString = exports.reduceTimes = exports.reduceSum = exports.sumAmount = exports.fillEndWithZero = exports.fillStartWithZero = exports.absFromSequence = exports.returnDates = exports.displayFrDatePeriode = exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = exports.genRandomNumberArray = exports.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.formatMonthYearToLocaleString = exports.calculPercent = exports.validEmail = exports.convertToCfa = exports.packAndUnit = exports.unCheckedAll = void 0;
|
|
6
|
+
exports.getPeriodDateColor = exports.getColorAccordingToDate = exports.genRandomColour = exports.formatNgbDate = exports.dateNth = exports.dateNthMonth = exports.dateNthDay = exports.dateNthWeek = exports.getNbOfDaysBetweenTwoDates = exports.displayDateRangeFr = exports.reformatDates = exports.firstDayOfDate = exports.dateToString = exports.dateDiff = exports.dateFormatter = exports.replaceSpacesWith = exports.replaceAllIn = exports.toPlural = exports.sesStorageGet = exports.sesStorageSet = exports.genSequenceRef = exports.refGenerator = exports.removeBackSlashOccurences = exports.stringifyFormatter = exports.removeString = exports.diffArraysByProp = exports.diffArraysByFunc = exports.deepClone = exports.findFirstSequenceMissing = exports.fillNumWithZero = exports.findSequencesMissing = exports.sequencesToNumbers = exports.notInSequence = exports.currencyFormatterCfa = exports.currencyFormatter = exports.checkAuth = exports.wakeUp = exports.sleep = exports.limitTo = exports.titleCase = exports.toObjectDate = exports.duplicateObjects = exports.removeDuplicateValues = exports.removeDuplicateObjects = exports.getRandomColor = exports.calPercent = exports.percentOf = exports.genDateMinutesStep = exports.formatDateFirstDayFr = exports.isEmpty = void 0;
|
|
7
|
+
exports.nthIndexOf = exports.pathName = exports.checkObjInArray = exports.arraySome = exports.winMaxHeight = exports.toggleProp = exports.roundLastNDigits = exports.removeParamKeyName = exports.countryIsoToFlag = exports.monthStringName = exports.returnBool = exports.formatAmountToString = exports.reduceTimes = exports.reduceSum = exports.sumAmount = exports.fillEndWithZero = exports.fillStartWithZero = exports.absFromSequence = exports.returnDates = exports.displayFrDatePeriode = exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = exports.genRandomNumberArray = 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 = void 0;
|
|
8
8
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
9
|
+
const dayOfYear_1 = __importDefault(require("dayjs/plugin/dayOfYear"));
|
|
9
10
|
const isSameOrBefore_1 = __importDefault(require("dayjs/plugin/isSameOrBefore"));
|
|
10
11
|
const relativeTime_1 = __importDefault(require("dayjs/plugin/relativeTime"));
|
|
11
12
|
const weekOfYear_1 = __importDefault(require("dayjs/plugin/weekOfYear"));
|
|
12
13
|
const lodash_1 = __importDefault(require("lodash"));
|
|
13
14
|
require("dayjs/locale/fr");
|
|
14
15
|
dayjs_1.default.extend(relativeTime_1.default);
|
|
16
|
+
dayjs_1.default.extend(isSameOrBefore_1.default);
|
|
15
17
|
dayjs_1.default.extend(weekOfYear_1.default);
|
|
18
|
+
dayjs_1.default.extend(dayOfYear_1.default);
|
|
16
19
|
dayjs_1.default.extend(isSameOrBefore_1.default);
|
|
17
20
|
// require("dayjs/locale/fr");
|
|
18
21
|
/* start: dates -------------------------------------- */
|
|
@@ -355,21 +358,6 @@ const dateFormatter = (date, format = "dmy", separator = "/") => {
|
|
|
355
358
|
}
|
|
356
359
|
};
|
|
357
360
|
exports.dateFormatter = dateFormatter;
|
|
358
|
-
const getNthWeek = (startDate, endDate, nthWeek) => {
|
|
359
|
-
let currentDate = (0, dayjs_1.default)(startDate);
|
|
360
|
-
let weeks = [];
|
|
361
|
-
while (currentDate.isSameOrBefore(endDate)) {
|
|
362
|
-
weeks.push(currentDate);
|
|
363
|
-
currentDate = currentDate.add(1, "week");
|
|
364
|
-
}
|
|
365
|
-
return weeks[nthWeek - 1];
|
|
366
|
-
};
|
|
367
|
-
exports.getNthWeek = getNthWeek;
|
|
368
|
-
const dateNthWeek = (startDate, endDate, nthWeek) => {
|
|
369
|
-
const week = (0, exports.getNthWeek)(startDate, endDate, nthWeek);
|
|
370
|
-
return (0, dayjs_1.default)(week.format("YYYY-MM-DD")).week();
|
|
371
|
-
};
|
|
372
|
-
exports.dateNthWeek = dateNthWeek;
|
|
373
361
|
const dateDiff = (date1, unit = "year", date2 = new Date()) => {
|
|
374
362
|
return (0, dayjs_1.default)(date2).diff(date1, unit);
|
|
375
363
|
};
|
|
@@ -403,6 +391,43 @@ const getNbOfDaysBetweenTwoDates = (date1, date2) => {
|
|
|
403
391
|
return Math.ceil(diff / day);
|
|
404
392
|
};
|
|
405
393
|
exports.getNbOfDaysBetweenTwoDates = getNbOfDaysBetweenTwoDates;
|
|
394
|
+
const getNthDate = (startDate, endDate, nthDate, periodicity) => {
|
|
395
|
+
let currentDate = (0, dayjs_1.default)(startDate);
|
|
396
|
+
let dates = [];
|
|
397
|
+
while (currentDate.isSameOrBefore(endDate)) {
|
|
398
|
+
dates.push(currentDate);
|
|
399
|
+
currentDate = currentDate.add(1, periodicity);
|
|
400
|
+
}
|
|
401
|
+
return dates[nthDate - 1];
|
|
402
|
+
};
|
|
403
|
+
const dateNthWeek = (startDate, endDate, nthWeek) => {
|
|
404
|
+
const week = getNthDate(startDate, endDate, nthWeek, "week");
|
|
405
|
+
return (0, dayjs_1.default)(week.format("YYYY-MM-DD")).week();
|
|
406
|
+
};
|
|
407
|
+
exports.dateNthWeek = dateNthWeek;
|
|
408
|
+
const dateNthDay = (startDate, endDate, nthday) => {
|
|
409
|
+
const day = getNthDate(startDate, endDate, nthday, "day");
|
|
410
|
+
return (0, dayjs_1.default)(day).dayOfYear();
|
|
411
|
+
};
|
|
412
|
+
exports.dateNthDay = dateNthDay;
|
|
413
|
+
const dateNthMonth = (startDate, endDate, nthMonth) => {
|
|
414
|
+
const month = getNthDate(startDate, endDate, nthMonth, "month");
|
|
415
|
+
return (0, dayjs_1.default)(month).get("month"); // +1 because month is 0-indexed in JavaScript
|
|
416
|
+
};
|
|
417
|
+
exports.dateNthMonth = dateNthMonth;
|
|
418
|
+
const dateNth = (startDate, endDate, nth, periodicity) => {
|
|
419
|
+
switch (periodicity) {
|
|
420
|
+
case "day":
|
|
421
|
+
return (0, exports.dateNthDay)(startDate, endDate, nth);
|
|
422
|
+
case "week":
|
|
423
|
+
return (0, exports.dateNthWeek)(startDate, endDate, nth);
|
|
424
|
+
case "month":
|
|
425
|
+
return (0, exports.dateNthMonth)(startDate, endDate, nth); //the current month as a number (0-11) 0 = January, 11 = December
|
|
426
|
+
default:
|
|
427
|
+
return (0, exports.dateNthWeek)(startDate, endDate, nth);
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
exports.dateNth = dateNth;
|
|
406
431
|
/* end: dates ---------------------------------------- */
|
|
407
432
|
// export const formatNgbDate = (date: DateSelected) => {
|
|
408
433
|
const formatNgbDate = (date) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/esm/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ConfigType, OpUnitType, QUnitType } from "dayjs";
|
|
2
|
+
import EDatePeriodicity from "./shared/models/EDatePeriodicity";
|
|
2
3
|
import "dayjs/locale/fr";
|
|
3
4
|
export declare const isEmpty: (str: string) => str is "";
|
|
4
5
|
export declare const formatDateFirstDayFr: (date: Date | any) => string;
|
|
@@ -45,8 +46,6 @@ export declare const toPlural: (word: string) => string;
|
|
|
45
46
|
export declare const replaceAllIn: (text: string, regex?: RegExp, toChar?: string) => string;
|
|
46
47
|
export declare const replaceSpacesWith: (text: string, toChar?: string) => string;
|
|
47
48
|
export declare const dateFormatter: (date: Date | string, format?: "y" | "ym" | "ymd" | "dmy" | "ago" | "md" | "dmy-hm" | "dmyfr" | "myfr" | "mfr-short" | "mfr-long", separator?: "/" | "" | "-") => string;
|
|
48
|
-
export declare const getNthWeek: (startDate: Date | string, endDate: Date | string, nthWeek: number) => dayjs.Dayjs;
|
|
49
|
-
export declare const dateNthWeek: (startDate: Date | string, endDate: Date | string, nthWeek: number) => number;
|
|
50
49
|
export declare const dateDiff: (date1: ConfigType, unit?: QUnitType | OpUnitType, date2?: Date) => number;
|
|
51
50
|
export declare const dateToString: (date: Date | any) => string;
|
|
52
51
|
export declare const firstDayOfDate: (date: Date | any) => string;
|
|
@@ -56,6 +55,10 @@ export declare const reformatDates: (fromDate: any, toDate: any) => {
|
|
|
56
55
|
};
|
|
57
56
|
export declare const displayDateRangeFr: (getFromDate?: any, getToDate?: any) => string;
|
|
58
57
|
export declare const getNbOfDaysBetweenTwoDates: (date1: Date, date2: Date) => number;
|
|
58
|
+
export declare const dateNthWeek: (startDate: any, endDate: any, nthWeek: number) => number;
|
|
59
|
+
export declare const dateNthDay: (startDate: any, endDate: any, nthday: number) => number;
|
|
60
|
+
export declare const dateNthMonth: (startDate: any, endDate: any, nthMonth: number) => number;
|
|
61
|
+
export declare const dateNth: (startDate: any, endDate: any, nth: number, periodicity: EDatePeriodicity) => number;
|
|
59
62
|
export declare const formatNgbDate: (date: any) => {
|
|
60
63
|
fromDate: string;
|
|
61
64
|
toDate: string;
|
package/lib/esm/utils.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import dayjs from "dayjs";
|
|
2
|
+
import dayOfYear from "dayjs/plugin/dayOfYear";
|
|
2
3
|
import isSameOrBefore from "dayjs/plugin/isSameOrBefore";
|
|
3
4
|
import relativeTime from "dayjs/plugin/relativeTime";
|
|
4
5
|
import weekOfYear from "dayjs/plugin/weekOfYear";
|
|
5
6
|
import lodash from "lodash";
|
|
6
7
|
import "dayjs/locale/fr";
|
|
7
8
|
dayjs.extend(relativeTime);
|
|
9
|
+
dayjs.extend(isSameOrBefore);
|
|
8
10
|
dayjs.extend(weekOfYear);
|
|
11
|
+
dayjs.extend(dayOfYear);
|
|
9
12
|
dayjs.extend(isSameOrBefore);
|
|
10
13
|
// require("dayjs/locale/fr");
|
|
11
14
|
/* start: dates -------------------------------------- */
|
|
@@ -312,19 +315,6 @@ export const dateFormatter = (date, format = "dmy", separator = "/") => {
|
|
|
312
315
|
// return dayjs(date).format(`YYYY${separator}MM${separator}DD`);
|
|
313
316
|
}
|
|
314
317
|
};
|
|
315
|
-
export const getNthWeek = (startDate, endDate, nthWeek) => {
|
|
316
|
-
let currentDate = dayjs(startDate);
|
|
317
|
-
let weeks = [];
|
|
318
|
-
while (currentDate.isSameOrBefore(endDate)) {
|
|
319
|
-
weeks.push(currentDate);
|
|
320
|
-
currentDate = currentDate.add(1, "week");
|
|
321
|
-
}
|
|
322
|
-
return weeks[nthWeek - 1];
|
|
323
|
-
};
|
|
324
|
-
export const dateNthWeek = (startDate, endDate, nthWeek) => {
|
|
325
|
-
const week = getNthWeek(startDate, endDate, nthWeek);
|
|
326
|
-
return dayjs(week.format("YYYY-MM-DD")).week();
|
|
327
|
-
};
|
|
328
318
|
export const dateDiff = (date1, unit = "year", date2 = new Date()) => {
|
|
329
319
|
return dayjs(date2).diff(date1, unit);
|
|
330
320
|
};
|
|
@@ -352,6 +342,39 @@ export const getNbOfDaysBetweenTwoDates = (date1, date2) => {
|
|
|
352
342
|
const diff = Math.abs(date2.getTime() - date1.getTime());
|
|
353
343
|
return Math.ceil(diff / day);
|
|
354
344
|
};
|
|
345
|
+
const getNthDate = (startDate, endDate, nthDate, periodicity) => {
|
|
346
|
+
let currentDate = dayjs(startDate);
|
|
347
|
+
let dates = [];
|
|
348
|
+
while (currentDate.isSameOrBefore(endDate)) {
|
|
349
|
+
dates.push(currentDate);
|
|
350
|
+
currentDate = currentDate.add(1, periodicity);
|
|
351
|
+
}
|
|
352
|
+
return dates[nthDate - 1];
|
|
353
|
+
};
|
|
354
|
+
export const dateNthWeek = (startDate, endDate, nthWeek) => {
|
|
355
|
+
const week = getNthDate(startDate, endDate, nthWeek, "week");
|
|
356
|
+
return dayjs(week.format("YYYY-MM-DD")).week();
|
|
357
|
+
};
|
|
358
|
+
export const dateNthDay = (startDate, endDate, nthday) => {
|
|
359
|
+
const day = getNthDate(startDate, endDate, nthday, "day");
|
|
360
|
+
return dayjs(day).dayOfYear();
|
|
361
|
+
};
|
|
362
|
+
export const dateNthMonth = (startDate, endDate, nthMonth) => {
|
|
363
|
+
const month = getNthDate(startDate, endDate, nthMonth, "month");
|
|
364
|
+
return dayjs(month).get("month"); // +1 because month is 0-indexed in JavaScript
|
|
365
|
+
};
|
|
366
|
+
export const dateNth = (startDate, endDate, nth, periodicity) => {
|
|
367
|
+
switch (periodicity) {
|
|
368
|
+
case "day":
|
|
369
|
+
return dateNthDay(startDate, endDate, nth);
|
|
370
|
+
case "week":
|
|
371
|
+
return dateNthWeek(startDate, endDate, nth);
|
|
372
|
+
case "month":
|
|
373
|
+
return dateNthMonth(startDate, endDate, nth); //the current month as a number (0-11) 0 = January, 11 = December
|
|
374
|
+
default:
|
|
375
|
+
return dateNthWeek(startDate, endDate, nth);
|
|
376
|
+
}
|
|
377
|
+
};
|
|
355
378
|
/* end: dates ---------------------------------------- */
|
|
356
379
|
// export const formatNgbDate = (date: DateSelected) => {
|
|
357
380
|
export const formatNgbDate = (date) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "asv-hlps",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.41",
|
|
4
4
|
"description": "helpers",
|
|
5
5
|
"main": "./lib/cjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
"author": "Aril Vignon",
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@types/express": "^5.0.
|
|
19
|
+
"@types/express": "^5.0.3",
|
|
20
20
|
"@types/jwt-decode": "^3.1.0",
|
|
21
|
-
"@types/lodash": "^4.17.
|
|
21
|
+
"@types/lodash": "^4.17.17",
|
|
22
22
|
"@types/pdfmake": "^0.2.11",
|
|
23
23
|
"@types/randomatic": "^3.1.5",
|
|
24
|
-
"@types/react": "^19.1.
|
|
24
|
+
"@types/react": "^19.1.7"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@tanstack/react-query": "^5.
|
|
27
|
+
"@tanstack/react-query": "^5.80.6",
|
|
28
28
|
"axios": "^1.9.0",
|
|
29
29
|
"class-validator": "^0.14.2",
|
|
30
30
|
"classnames": "^2.5.1",
|
|
@@ -37,6 +37,6 @@
|
|
|
37
37
|
"typeorm": "^0.3.24",
|
|
38
38
|
"typescript": "^5.8.3",
|
|
39
39
|
"yup": "^1.6.1",
|
|
40
|
-
"zustand": "^5.0.
|
|
40
|
+
"zustand": "^5.0.5"
|
|
41
41
|
}
|
|
42
42
|
}
|