asv-hlps 1.4.17 → 1.4.19
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/utils.d.ts +3 -1
- package/lib/cjs/utils.js +21 -2
- package/lib/esm/utils.d.ts +3 -1
- package/lib/esm/utils.js +17 -0
- package/package.json +1 -3
package/lib/cjs/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigType, OpUnitType, QUnitType } from "dayjs";
|
|
1
|
+
import dayjs, { ConfigType, OpUnitType, QUnitType } from "dayjs";
|
|
2
2
|
import "dayjs/locale/fr";
|
|
3
3
|
export declare const isEmpty: (str: string) => str is "";
|
|
4
4
|
export declare const formatDateFirstDayFr: (date: Date | any) => string;
|
|
@@ -46,6 +46,8 @@ export declare const toPlural: (word: string) => string;
|
|
|
46
46
|
export declare const replaceAllIn: (text: string, regex?: RegExp, toChar?: string) => string;
|
|
47
47
|
export declare const replaceSpacesWith: (text: string, toChar?: string) => string;
|
|
48
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;
|
|
49
|
+
export declare const getNthWeek: (startDate: Date | string, endDate: Date | string, nthWeek: number) => dayjs.Dayjs;
|
|
50
|
+
export declare const dateNthWeek: (startDate: Date | string, endDate: Date | string, nthWeek: number) => number;
|
|
49
51
|
export declare const dateDiff: (date1: ConfigType, unit?: QUnitType | OpUnitType, date2?: Date) => number;
|
|
50
52
|
export declare const dateToString: (date: Date | any) => string;
|
|
51
53
|
export declare const firstDayOfDate: (date: Date | any) => string;
|
package/lib/cjs/utils.js
CHANGED
|
@@ -3,13 +3,17 @@ 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.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.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.formatMonthYearToLocaleString = exports.calculPercent = exports.validEmail = exports.convertToCfa = exports.packAndUnit = void 0;
|
|
6
|
+
exports.arrayMultiChecked = exports.getPeriodDateColor = exports.getColorAccordingToDate = exports.genRandomColour = exports.formatNgbDate = exports.getNbOfDaysBetweenTwoDates = exports.displayDateRangeFr = exports.reformatDates = exports.firstDayOfDate = exports.dateToString = exports.dateDiff = exports.dateNthWeek = exports.getNthWeek = 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.formatToStringCfa = exports.currencyFormatter = exports.formatToString = exports.checkAuth = exports.wakeUp = exports.sleep = exports.limitTo = exports.titleCase = exports.toObjectDate = exports.duplicateObjects = exports.removeDuplicateObjects = exports.getRandomColor = exports.calPercent = exports.percentOf = exports.genDateMinutesStep = exports.formatDateFirstDayFr = exports.isEmpty = void 0;
|
|
7
|
+
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.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 = void 0;
|
|
8
8
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
9
|
+
const isSameOrBefore_1 = __importDefault(require("dayjs/plugin/isSameOrBefore"));
|
|
9
10
|
const relativeTime_1 = __importDefault(require("dayjs/plugin/relativeTime"));
|
|
11
|
+
const weekOfYear_1 = __importDefault(require("dayjs/plugin/weekOfYear"));
|
|
10
12
|
const lodash_1 = __importDefault(require("lodash"));
|
|
11
13
|
require("dayjs/locale/fr");
|
|
12
14
|
dayjs_1.default.extend(relativeTime_1.default);
|
|
15
|
+
dayjs_1.default.extend(weekOfYear_1.default);
|
|
16
|
+
dayjs_1.default.extend(isSameOrBefore_1.default);
|
|
13
17
|
// require("dayjs/locale/fr");
|
|
14
18
|
/* start: dates -------------------------------------- */
|
|
15
19
|
/* end: dates ---------------------------------------- */
|
|
@@ -359,6 +363,21 @@ const dateFormatter = (date, format = "dmy", separator = "/") => {
|
|
|
359
363
|
}
|
|
360
364
|
};
|
|
361
365
|
exports.dateFormatter = dateFormatter;
|
|
366
|
+
const getNthWeek = (startDate, endDate, nthWeek) => {
|
|
367
|
+
let currentDate = (0, dayjs_1.default)(startDate);
|
|
368
|
+
let weeks = [];
|
|
369
|
+
while (currentDate.isSameOrBefore(endDate)) {
|
|
370
|
+
weeks.push(currentDate);
|
|
371
|
+
currentDate = currentDate.add(1, "week");
|
|
372
|
+
}
|
|
373
|
+
return weeks[nthWeek - 1];
|
|
374
|
+
};
|
|
375
|
+
exports.getNthWeek = getNthWeek;
|
|
376
|
+
const dateNthWeek = (startDate, endDate, nthWeek) => {
|
|
377
|
+
const week = (0, exports.getNthWeek)(startDate, endDate, nthWeek);
|
|
378
|
+
return (0, dayjs_1.default)(week.format("YYYY-MM-DD")).week();
|
|
379
|
+
};
|
|
380
|
+
exports.dateNthWeek = dateNthWeek;
|
|
362
381
|
const dateDiff = (date1, unit = "year", date2 = new Date()) => {
|
|
363
382
|
return (0, dayjs_1.default)(date2).diff(date1, unit);
|
|
364
383
|
};
|
package/lib/esm/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigType, OpUnitType, QUnitType } from "dayjs";
|
|
1
|
+
import dayjs, { ConfigType, OpUnitType, QUnitType } from "dayjs";
|
|
2
2
|
import "dayjs/locale/fr";
|
|
3
3
|
export declare const isEmpty: (str: string) => str is "";
|
|
4
4
|
export declare const formatDateFirstDayFr: (date: Date | any) => string;
|
|
@@ -46,6 +46,8 @@ export declare const toPlural: (word: string) => string;
|
|
|
46
46
|
export declare const replaceAllIn: (text: string, regex?: RegExp, toChar?: string) => string;
|
|
47
47
|
export declare const replaceSpacesWith: (text: string, toChar?: string) => string;
|
|
48
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;
|
|
49
|
+
export declare const getNthWeek: (startDate: Date | string, endDate: Date | string, nthWeek: number) => dayjs.Dayjs;
|
|
50
|
+
export declare const dateNthWeek: (startDate: Date | string, endDate: Date | string, nthWeek: number) => number;
|
|
49
51
|
export declare const dateDiff: (date1: ConfigType, unit?: QUnitType | OpUnitType, date2?: Date) => number;
|
|
50
52
|
export declare const dateToString: (date: Date | any) => string;
|
|
51
53
|
export declare const firstDayOfDate: (date: Date | any) => string;
|
package/lib/esm/utils.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import dayjs from "dayjs";
|
|
2
|
+
import isSameOrBefore from "dayjs/plugin/isSameOrBefore";
|
|
2
3
|
import relativeTime from "dayjs/plugin/relativeTime";
|
|
4
|
+
import weekOfYear from "dayjs/plugin/weekOfYear";
|
|
3
5
|
import lodash from "lodash";
|
|
4
6
|
import "dayjs/locale/fr";
|
|
5
7
|
dayjs.extend(relativeTime);
|
|
8
|
+
dayjs.extend(weekOfYear);
|
|
9
|
+
dayjs.extend(isSameOrBefore);
|
|
6
10
|
// require("dayjs/locale/fr");
|
|
7
11
|
/* start: dates -------------------------------------- */
|
|
8
12
|
/* end: dates ---------------------------------------- */
|
|
@@ -315,6 +319,19 @@ export const dateFormatter = (date, format = "dmy", separator = "/") => {
|
|
|
315
319
|
// return dayjs(date).format(`YYYY${separator}MM${separator}DD`);
|
|
316
320
|
}
|
|
317
321
|
};
|
|
322
|
+
export const getNthWeek = (startDate, endDate, nthWeek) => {
|
|
323
|
+
let currentDate = dayjs(startDate);
|
|
324
|
+
let weeks = [];
|
|
325
|
+
while (currentDate.isSameOrBefore(endDate)) {
|
|
326
|
+
weeks.push(currentDate);
|
|
327
|
+
currentDate = currentDate.add(1, "week");
|
|
328
|
+
}
|
|
329
|
+
return weeks[nthWeek - 1];
|
|
330
|
+
};
|
|
331
|
+
export const dateNthWeek = (startDate, endDate, nthWeek) => {
|
|
332
|
+
const week = getNthWeek(startDate, endDate, nthWeek);
|
|
333
|
+
return dayjs(week.format("YYYY-MM-DD")).week();
|
|
334
|
+
};
|
|
318
335
|
export const dateDiff = (date1, unit = "year", date2 = new Date()) => {
|
|
319
336
|
return dayjs(date2).diff(date1, unit);
|
|
320
337
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "asv-hlps",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.19",
|
|
4
4
|
"description": "helpers",
|
|
5
5
|
"main": "./lib/cjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"author": "Aril Vignon",
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@types/bcryptjs": "^2.4.6",
|
|
20
19
|
"@types/express": "^5.0.0",
|
|
21
20
|
"@types/jwt-decode": "^3.1.0",
|
|
22
21
|
"@types/lodash": "^4.17.16",
|
|
@@ -26,7 +25,6 @@
|
|
|
26
25
|
},
|
|
27
26
|
"dependencies": {
|
|
28
27
|
"axios": "^1.8.2",
|
|
29
|
-
"bcryptjs": "^3.0.2",
|
|
30
28
|
"class-validator": "^0.14.1",
|
|
31
29
|
"classnames": "^2.5.1",
|
|
32
30
|
"dayjs": "^1.11.13",
|