@rh-support/utils 2.1.37 → 2.1.38

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.
@@ -11,6 +11,7 @@ type AddToDate = {
11
11
  date?: string;
12
12
  };
13
13
  export declare const addDaysToDate: (params: AddToDate) => moment.Moment;
14
+ export declare const isValidDate: (dateString: string) => boolean;
14
15
  export declare const trafficSplit: (testVariationWeight: number, dateString: string) => "A" | "B";
15
16
  export {};
16
17
  //# sourceMappingURL=dateUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dateUtils.d.ts","sourceRoot":"","sources":["../../src/dateUtils.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,eAAO,MAAM,UAAU,wCAGX,KAAK,qBAAqB,WASrC,CAAC;AAEF,eAAO,MAAM,cAAc,wCAGf,KAAK,qBAAqB,WAerC,CAAC;AAEF,eAAO,MAAM,OAAO,SAAU,MAAM,KAAG,MAAmC,CAAC;AAE3E,eAAO,MAAM,2BAA2B,WAAY,MAAM,WAEzD,CAAC;AAEF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,MAExD,CAAC;AAEF,eAAO,MAAM,+BAA+B,SAClC,MAAM,gBACC,OAAO,UAAU,CAAC,OAAO,KACvC,OAEF,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,gBAAe,OAAO,UAAU,CAAC,OAAO,YAEhF,CAAC;AAEF,KAAK,SAAS,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,aAAa,WAAY,SAAS,kBAG9C,CAAC;AAQF,eAAO,MAAM,YAAY,wBAAyB,MAAM,cAAc,MAAM,cAe3E,CAAC"}
1
+ {"version":3,"file":"dateUtils.d.ts","sourceRoot":"","sources":["../../src/dateUtils.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,eAAO,MAAM,UAAU,wCAGX,KAAK,qBAAqB,WASrC,CAAC;AAEF,eAAO,MAAM,cAAc,wCAGf,KAAK,qBAAqB,WAerC,CAAC;AAEF,eAAO,MAAM,OAAO,SAAU,MAAM,KAAG,MAAmC,CAAC;AAE3E,eAAO,MAAM,2BAA2B,WAAY,MAAM,WAEzD,CAAC;AAEF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,MAExD,CAAC;AAEF,eAAO,MAAM,+BAA+B,SAClC,MAAM,gBACC,OAAO,UAAU,CAAC,OAAO,KACvC,OAEF,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,gBAAe,OAAO,UAAU,CAAC,OAAO,YAEhF,CAAC;AAEF,KAAK,SAAS,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,aAAa,WAAY,SAAS,kBAG9C,CAAC;AAEF,eAAO,MAAM,WAAW,eAAgB,MAAM,YAI7C,CAAC;AAQF,eAAO,MAAM,YAAY,wBAAyB,MAAM,cAAc,MAAM,cAe3E,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { isValid, parseISO } from 'date-fns';
1
2
  import moment from 'moment-timezone';
2
3
  export const formatDate = (date, locale = 'en-us', format = { month: 'short', day: 'numeric', year: 'numeric' }) => {
3
4
  if (!date) {
@@ -40,6 +41,10 @@ export const addDaysToDate = (params) => {
40
41
  const { days, date = new Date() } = params;
41
42
  return moment(date).add(days, 'days');
42
43
  };
44
+ export const isValidDate = (dateString) => {
45
+ const parsedDate = parseISO(dateString);
46
+ return isValid(parsedDate);
47
+ };
43
48
  // split traffic based on time and weight
44
49
  // for example, if testVariationWeight is 2 and the current time in seconds modulo 10 is less than 2,
45
50
  // redirect to test version (20% of the time), else redirect to control version (80% of the time)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/utils",
3
- "version": "2.1.37",
3
+ "version": "2.1.38",
4
4
  "description": "> TODO: description",
5
5
  "author": "Vikas Rathee <vrathee@redhat.com>",
6
6
  "license": "ISC",
@@ -41,7 +41,7 @@
41
41
  "prepublishOnly": "npm run build"
42
42
  },
43
43
  "peerDependencies": {
44
- "@cee-eng/hydrajs": "4.17.21",
44
+ "@cee-eng/hydrajs": "4.17.24",
45
45
  "@cee-eng/ui-toolkit": "1.1.8",
46
46
  "dompurify": "^2.2.6",
47
47
  "i18next": "^22.5.1",
@@ -55,9 +55,10 @@
55
55
  "solr-query-builder": "1.0.1"
56
56
  },
57
57
  "dependencies": {
58
- "@cee-eng/hydrajs": "4.17.21",
58
+ "@cee-eng/hydrajs": "4.17.24",
59
59
  "@cee-eng/ui-toolkit": "1.1.8",
60
60
  "@rh-support/types": "2.0.4",
61
+ "date-fns": "3.6.0",
61
62
  "dompurify": "^2.2.6",
62
63
  "dot": "^1.1.3",
63
64
  "i18next": "^22.5.1",
@@ -93,5 +94,5 @@
93
94
  "defaults and supports es6-module",
94
95
  "maintained node versions"
95
96
  ],
96
- "gitHead": "fe9dac0d0d3517281da0692cf84070b998b22f78"
97
+ "gitHead": "87ee594dd371e4838eb7ff7d381f548ce8ae2b94"
97
98
  }