@molochko-dev/data 1.4.111 → 1.4.112

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.
@@ -1,2 +1,2 @@
1
1
  export declare const getMonthFromDate: (dateString: string) => number;
2
- export declare function datestrToDate(dateStr: string): Date;
2
+ export declare function datestrToDate(dateStr: string): Date | null;
@@ -12,6 +12,10 @@ const getMonthFromDate = (dateString) => {
12
12
  exports.getMonthFromDate = getMonthFromDate;
13
13
  /* преобразование строки 251201 в дату*/
14
14
  function datestrToDate(dateStr) {
15
+ const re = /^((25|26|27|28|29|30|31|32|33)(01|02|03|04|05|06|07|08|09|10|11|12)\d\d)$/;
16
+ if (!re.test(dateStr)) {
17
+ return null;
18
+ }
15
19
  const year = '20' + dateStr.substring(0, 2); // 2022
16
20
  const month = dateStr.substring(2, 4); // 12
17
21
  const day = dateStr.substring(4, 6); // 02
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molochko-dev/data",
3
- "version": "1.4.111",
3
+ "version": "1.4.112",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "typings/index.d.ts",
@@ -6,7 +6,11 @@ export const getMonthFromDate = (dateString: string) => {
6
6
  };
7
7
 
8
8
  /* преобразование строки 251201 в дату*/
9
- export function datestrToDate(dateStr: string): Date {
9
+ export function datestrToDate(dateStr: string): Date | null {
10
+ const re = /^((25|26|27|28|29|30|31|32|33)(01|02|03|04|05|06|07|08|09|10|11|12)\d\d)$/;
11
+ if (!re.test(dateStr)) {
12
+ return null;
13
+ }
10
14
  const year = '20' + dateStr.substring(0, 2); // 2022
11
15
  const month = dateStr.substring(2, 4); // 12
12
16
  const day = dateStr.substring(4, 6); // 02