@react-pakistan/util-functions 1.23.18 → 1.23.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.
@@ -1,5 +1,6 @@
1
1
  export declare enum DATE_FORMATS {
2
2
  LOCALE_DATE = "LOCALE_DATE",
3
- DD_MM = "DD_MM"
3
+ DD_MM = "DD_MM",
4
+ YYYY_MM_DD = "YYYY_MM_DD"
4
5
  }
5
6
  export declare const formatDate: (str: string, format: DATE_FORMATS) => string;
@@ -6,12 +6,14 @@ var DATE_FORMATS;
6
6
  (function (DATE_FORMATS) {
7
7
  DATE_FORMATS["LOCALE_DATE"] = "LOCALE_DATE";
8
8
  DATE_FORMATS["DD_MM"] = "DD_MM";
9
+ DATE_FORMATS["YYYY_MM_DD"] = "YYYY_MM_DD";
9
10
  })(DATE_FORMATS || (exports.DATE_FORMATS = DATE_FORMATS = {}));
10
11
  const formatDate = (str, format) => {
11
- const formattedDate = new Date(str);
12
+ const dateObj = new Date(str);
12
13
  const dateMap = {
13
- [DATE_FORMATS.LOCALE_DATE]: formattedDate.toLocaleDateString(),
14
- [DATE_FORMATS.DD_MM]: `${formattedDate.getDate()} ${(0, get_month_name_1.getMonthName)(formattedDate.getMonth())}`,
14
+ [DATE_FORMATS.LOCALE_DATE]: dateObj.toLocaleDateString(),
15
+ [DATE_FORMATS.DD_MM]: `${dateObj.getDate()} ${(0, get_month_name_1.getMonthName)(dateObj.getMonth())}`,
16
+ [DATE_FORMATS.YYYY_MM_DD]: `${dateObj.getFullYear}-${dateObj.getMonth().toFixed(2)}-${dateObj.getDate()}`,
15
17
  };
16
18
  return dateMap[format];
17
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pakistan/util-functions",
3
- "version": "1.23.18",
3
+ "version": "1.23.19",
4
4
  "description": "A library of all util functions",
5
5
  "main": "index.js",
6
6
  "scripts": {