@capillarytech/cap-ui-utils 3.0.9-alpha.7 → 3.0.9
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.
- package/package.json +1 -1
- package/utils/timezone.js +7 -10
package/package.json
CHANGED
package/utils/timezone.js
CHANGED
|
@@ -40,10 +40,9 @@ const DST_NEUTRAL_TZ_MAP = {
|
|
|
40
40
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
const getTimezoneFormattedDate = (date,orgTZ = false,
|
|
43
|
+
const getTimezoneFormattedDate = (date,orgTZ = false,customTZ = null) => {
|
|
44
44
|
const orgTimezone = utilsLocalStorageApi.loadItem("orgTZ") || "Asia/Kolkata";
|
|
45
|
-
const
|
|
46
|
-
const targetTimezone = customTZ || (serverTZ ? serverTimezone : orgTZ ? orgTimezone : orgTimezone);
|
|
45
|
+
const targetTimezone = customTZ || (orgTZ ? orgTimezone : orgTimezone);
|
|
47
46
|
let momentDate;
|
|
48
47
|
|
|
49
48
|
// If date is epoch (number or numeric string)
|
|
@@ -90,9 +89,8 @@ const getTimezoneFormattedDate = (date,orgTZ = false,serverTZ = false,customTZ =
|
|
|
90
89
|
*
|
|
91
90
|
* Timezone Selection Priority:
|
|
92
91
|
* 1. customTZ (if provided) - overrides all others
|
|
93
|
-
* 2.
|
|
94
|
-
* 3.
|
|
95
|
-
* 4. Default → uses organization timezone from localStorage
|
|
92
|
+
* 2. orgTZ=true → uses organization timezone from localStorage
|
|
93
|
+
* 3. Default → uses organization timezone from localStorage
|
|
96
94
|
*
|
|
97
95
|
* Input Handling:
|
|
98
96
|
* - Epoch input (number or numeric string):
|
|
@@ -105,16 +103,15 @@ const getTimezoneFormattedDate = (date,orgTZ = false,serverTZ = false,customTZ =
|
|
|
105
103
|
* - Converts to target timezone
|
|
106
104
|
*
|
|
107
105
|
* @param {string|number|Date} date - Epoch timestamp, ISO string with timezone, or Date object.
|
|
108
|
-
* @param {boolean} orgTZ - Whether to force conversion into organization timezone.
|
|
109
|
-
* @param {boolean} serverTZ - Whether to force conversion into server timezone.
|
|
106
|
+
* @param {boolean} orgTZ - Whether to force conversion into organization timezone. Default is true.
|
|
110
107
|
* @param {string|null} customTZ - Custom timezone override (e.g., "Asia/Kolkata").
|
|
111
108
|
* @returns {string} Formatted date string with timezone abbreviation or '-'.
|
|
112
109
|
*/
|
|
113
|
-
export const formatDateWithTimezone = (date, orgTZ =
|
|
110
|
+
export const formatDateWithTimezone = (date, orgTZ = true, customTZ = null) => {
|
|
114
111
|
try {
|
|
115
112
|
if (!date) return "-";
|
|
116
113
|
|
|
117
|
-
const momentDate = getTimezoneFormattedDate(date,orgTZ,
|
|
114
|
+
const momentDate = getTimezoneFormattedDate(date,orgTZ,customTZ);
|
|
118
115
|
if (!momentDate.isValid()) return "-";
|
|
119
116
|
|
|
120
117
|
let tzAbbr = momentDate.format("z");
|