asv-hlps 1.2.93 → 1.2.94

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.
@@ -58,7 +58,7 @@ export declare const formatNgbDate: (date: any) => {
58
58
  };
59
59
  export declare const genRandomColour: () => string;
60
60
  export declare const getColorAccordingToDate: (inputDate: Date, period1?: number, period2?: number, period3?: number, ifClass?: boolean) => "red" | "DarkOrange" | "turquoise" | "blue" | "green" | "#f46a6a" | "#f1b44c" | "#cce5ff" | "#34c38f" | "#339900";
61
- export declare const getPeriodDateColor: (inputDate: Date, period1?: number, period2?: number, period3?: number, ifClass?: boolean) => "danger" | "warning" | "purple" | "success" | "info";
61
+ export declare const getPeriodDateColor: (inputDate: string, period?: number) => "danger" | "warning" | "purple" | "success" | "info";
62
62
  export declare const arrayMultiChecked: (objet: any[], event: boolean, item: any) => any[];
63
63
  export declare const inputChecked: (event: any, item: any, checks: any[], isChecked?: boolean) => any[];
64
64
  export declare const unCheckedAll: (checks?: any[]) => void;
package/lib/cjs/utils.js CHANGED
@@ -336,26 +336,34 @@ const getColorAccordingToDate = (inputDate, period1 = 3, period2 = 6, period3 =
336
336
  return "#339900";
337
337
  };
338
338
  exports.getColorAccordingToDate = getColorAccordingToDate;
339
- const getPeriodDateColor = (inputDate, period1 = 3, period2 = 6, period3 = 9, ifClass) => {
340
- const date = new Date();
341
- const date2 = new Date(inputDate);
342
- const diffNumber = Math.ceil((0, exports.getNbOfDaysBetweenTwoDates)(date2, date));
343
- period1 = period1 * 30;
344
- period2 = period2 * 30;
345
- period3 = period3 * 30;
346
- if (diffNumber <= period1) {
339
+ const getPeriodDateColor = (inputDate, period = 30) => {
340
+ const month0 = 0;
341
+ const month3 = period * 3;
342
+ const month6 = period * 6;
343
+ const month9 = period * 9;
344
+ const month12 = period * 12;
345
+ const today = (0, dayjs_1.default)(new Date());
346
+ const expDate = new Date(inputDate);
347
+ const diff = (0, dayjs_1.default)(expDate).diff(today, "day");
348
+ if (diff <= month0) {
349
+ // return "dark";
347
350
  return "danger";
348
351
  }
349
- else if (diffNumber > period1 && diffNumber <= period2) {
352
+ if (diff <= month3) {
353
+ return "danger";
354
+ }
355
+ if (diff <= month6) {
350
356
  return "warning";
351
357
  }
352
- else if (diffNumber > period2 && diffNumber <= period3) {
358
+ if (diff <= month9) {
353
359
  return "purple";
354
360
  }
355
- else if (diffNumber > period3) {
361
+ if (diff <= month12) {
356
362
  return "success";
357
363
  }
358
- return "info";
364
+ if (diff > month12) {
365
+ return "info";
366
+ }
359
367
  };
360
368
  exports.getPeriodDateColor = getPeriodDateColor;
361
369
  const arrayMultiChecked = (objet, event, item) => {
@@ -58,7 +58,7 @@ export declare const formatNgbDate: (date: any) => {
58
58
  };
59
59
  export declare const genRandomColour: () => string;
60
60
  export declare const getColorAccordingToDate: (inputDate: Date, period1?: number, period2?: number, period3?: number, ifClass?: boolean) => "red" | "DarkOrange" | "turquoise" | "blue" | "green" | "#f46a6a" | "#f1b44c" | "#cce5ff" | "#34c38f" | "#339900";
61
- export declare const getPeriodDateColor: (inputDate: Date, period1?: number, period2?: number, period3?: number, ifClass?: boolean) => "danger" | "warning" | "purple" | "success" | "info";
61
+ export declare const getPeriodDateColor: (inputDate: string, period?: number) => "danger" | "warning" | "purple" | "success" | "info";
62
62
  export declare const arrayMultiChecked: (objet: any[], event: boolean, item: any) => any[];
63
63
  export declare const inputChecked: (event: any, item: any, checks: any[], isChecked?: boolean) => any[];
64
64
  export declare const unCheckedAll: (checks?: any[]) => void;
package/lib/esm/utils.js CHANGED
@@ -284,26 +284,34 @@ export const getColorAccordingToDate = (inputDate, period1 = 3, period2 = 6, per
284
284
  }
285
285
  return "#339900";
286
286
  };
287
- export const getPeriodDateColor = (inputDate, period1 = 3, period2 = 6, period3 = 9, ifClass) => {
288
- const date = new Date();
289
- const date2 = new Date(inputDate);
290
- const diffNumber = Math.ceil(getNbOfDaysBetweenTwoDates(date2, date));
291
- period1 = period1 * 30;
292
- period2 = period2 * 30;
293
- period3 = period3 * 30;
294
- if (diffNumber <= period1) {
287
+ export const getPeriodDateColor = (inputDate, period = 30) => {
288
+ const month0 = 0;
289
+ const month3 = period * 3;
290
+ const month6 = period * 6;
291
+ const month9 = period * 9;
292
+ const month12 = period * 12;
293
+ const today = dayjs(new Date());
294
+ const expDate = new Date(inputDate);
295
+ const diff = dayjs(expDate).diff(today, "day");
296
+ if (diff <= month0) {
297
+ // return "dark";
295
298
  return "danger";
296
299
  }
297
- else if (diffNumber > period1 && diffNumber <= period2) {
300
+ if (diff <= month3) {
301
+ return "danger";
302
+ }
303
+ if (diff <= month6) {
298
304
  return "warning";
299
305
  }
300
- else if (diffNumber > period2 && diffNumber <= period3) {
306
+ if (diff <= month9) {
301
307
  return "purple";
302
308
  }
303
- else if (diffNumber > period3) {
309
+ if (diff <= month12) {
304
310
  return "success";
305
311
  }
306
- return "info";
312
+ if (diff > month12) {
313
+ return "info";
314
+ }
307
315
  };
308
316
  export const arrayMultiChecked = (objet, event, item) => {
309
317
  const findItem = objet.find((x) => x.id === item.id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asv-hlps",
3
- "version": "1.2.93",
3
+ "version": "1.2.94",
4
4
  "description": "helpers",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",