@capillarytech/cap-ui-utils 3.0.7-alpha.3 → 3.0.7-alpha.5
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 +17 -20
package/package.json
CHANGED
package/utils/timezone.js
CHANGED
|
@@ -65,27 +65,24 @@ export const formatDateWithTimezone = (date, orgTZ = false) => {
|
|
|
65
65
|
export const getTimezoneTooltip = (date, orgTZ = false) => {
|
|
66
66
|
const orgTimezone = utilsLocalStorageApi.loadItem("orgTZ") || "Asia/Kolkata";
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
if (typeof date === "number" || (typeof date === "string" && /^\d+$/.test(date))) {
|
|
70
|
-
return `Timezone: ${orgTimezone} (UTC${moment.tz(orgTimezone).format("Z")})`;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Case 2: orgTZ = true → always use orgTZ
|
|
74
|
-
if (orgTZ) {
|
|
68
|
+
if(orgTZ){
|
|
75
69
|
return `Timezone: ${orgTimezone} (UTC${moment.tz(orgTimezone).format("Z")})`;
|
|
76
70
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
71
|
+
else{
|
|
72
|
+
// case 1: epoch number or numeric string
|
|
73
|
+
if(typeof date === "number" || (typeof date === "string" && /^\d+$/.test(date))){
|
|
74
|
+
return `Timezone: ${orgTimezone} (UTC${moment.tz(orgTimezone).format("Z")})`;
|
|
75
|
+
}
|
|
76
|
+
// case 2: ISO string or Date object
|
|
77
|
+
else{
|
|
78
|
+
let m = moment.parseZone(date); // handles ISO strings like 2025-08-12T23:59:59.000Z or 2025-08-12T23:59:59+05:30
|
|
79
|
+
if(!m.isValid()){
|
|
80
|
+
m = moment.tz(date, "DD MMM YYYY h:mm A z"); // handles strings like 17 Sep 2025 6:00 AM EDT
|
|
81
|
+
}
|
|
82
|
+
if(!m.isValid() || m.isUTC()){
|
|
83
|
+
return `Timezone: ${orgTimezone} (UTC${moment.tz(orgTimezone).format("Z")})`; // fallback to orgTZ
|
|
84
|
+
}
|
|
85
|
+
return `Timezone: ${m.tz() || orgTimezone} (UTC${m.format("Z")})`; // return the timezone and offset
|
|
86
|
+
}
|
|
88
87
|
}
|
|
89
|
-
|
|
90
|
-
return `Timezone: ${m.tz() || orgTimezone} (UTC${m.format("Z")})`;
|
|
91
88
|
};
|