@react-pakistan/util-functions 1.24.85 → 1.24.86

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.
@@ -4,6 +4,7 @@ export declare enum DATE_FORMATS {
4
4
  YYYY_MM_DD = "YYYY_MM_DD",
5
5
  DAY_DD_MM_YYYY = "DAY_DD_MM_YYYY",
6
6
  DAY_DD_MM_YY_COMPACT = "DAY_DD_MM_YY_COMPACT",
7
- HH_MM_AM_PM = "HH_MM_AM_PM"
7
+ HH_MM_AM_PM = "HH_MM_AM_PM",
8
+ HH_MM_SS_AM_PM = "HH_MM_SS_AM_PM"
8
9
  }
9
10
  export declare const formatDate: (str: string, format: DATE_FORMATS) => string;
@@ -11,6 +11,7 @@ var DATE_FORMATS;
11
11
  DATE_FORMATS["DAY_DD_MM_YYYY"] = "DAY_DD_MM_YYYY";
12
12
  DATE_FORMATS["DAY_DD_MM_YY_COMPACT"] = "DAY_DD_MM_YY_COMPACT";
13
13
  DATE_FORMATS["HH_MM_AM_PM"] = "HH_MM_AM_PM";
14
+ DATE_FORMATS["HH_MM_SS_AM_PM"] = "HH_MM_SS_AM_PM";
14
15
  })(DATE_FORMATS || (exports.DATE_FORMATS = DATE_FORMATS = {}));
15
16
  var formatDate = function (str, format) {
16
17
  var _a;
@@ -24,13 +25,15 @@ var formatDate = function (str, format) {
24
25
  var dateNumberInTowDigits = String(cleanDateNumber).length < 2
25
26
  ? "0".concat(cleanDateNumber)
26
27
  : cleanDateNumber;
27
- // Format time for HH:MM AM/PM
28
+ // Format time for HH:MM AM/PM and HH:MM:SS AM/PM
28
29
  var hours = dateObj.getHours();
29
30
  var minutes = dateObj.getMinutes();
31
+ var seconds = dateObj.getSeconds();
30
32
  var ampm = hours >= 12 ? 'PM' : 'AM';
31
33
  hours = hours % 12;
32
34
  hours = hours ? hours : 12; // the hour '0' should be '12'
33
35
  var minutesInTwoDigits = minutes < 10 ? "0".concat(minutes) : minutes;
36
+ var secondsInTwoDigits = seconds < 10 ? "0".concat(seconds) : seconds;
34
37
  var hoursInTwoDigits = hours < 10 ? "0".concat(hours) : hours;
35
38
  var dateMap = (_a = {},
36
39
  _a[DATE_FORMATS.LOCALE_DATE] = dateObj.toLocaleDateString(),
@@ -39,6 +42,7 @@ var formatDate = function (str, format) {
39
42
  _a[DATE_FORMATS.DAY_DD_MM_YYYY] = "".concat((0, get_day_name_1.getDayName)(dateObj.getDay()), ", ").concat(dateObj.getDate(), " ").concat((0, get_month_name_1.getMonthName)(dateObj.getMonth()), " ").concat(dateObj.getFullYear()),
40
43
  _a[DATE_FORMATS.DAY_DD_MM_YY_COMPACT] = "".concat((_b = (0, get_day_name_1.getDayName)(dateObj.getDay())) === null || _b === void 0 ? void 0 : _b.slice(0, 3), ", ").concat(dateObj.getDate(), " ").concat((0, get_month_name_1.getMonthName)(dateObj.getMonth()), " ").concat((_c = String(dateObj.getFullYear())) === null || _c === void 0 ? void 0 : _c.slice(2, 5)),
41
44
  _a[DATE_FORMATS.HH_MM_AM_PM] = "".concat(hoursInTwoDigits, ":").concat(minutesInTwoDigits, " ").concat(ampm),
45
+ _a[DATE_FORMATS.HH_MM_SS_AM_PM] = "".concat(hoursInTwoDigits, ":").concat(minutesInTwoDigits, ":").concat(secondsInTwoDigits, " ").concat(ampm),
42
46
  _a);
43
47
  return dateMap[format];
44
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pakistan/util-functions",
3
- "version": "1.24.85",
3
+ "version": "1.24.86",
4
4
  "description": "A library of all util functions",
5
5
  "main": "index.js",
6
6
  "scripts": {