@capillarytech/cap-ui-utils 3.0.7-alpha.5 → 3.0.7-alpha.7
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 -4
package/package.json
CHANGED
package/utils/timezone.js
CHANGED
|
@@ -40,10 +40,12 @@ export const formatDateWithTimezone = (date, orgTZ = false) => {
|
|
|
40
40
|
if (!momentDate.isValid()) return "-";
|
|
41
41
|
|
|
42
42
|
// Get strict timezone abbreviation (no offsets like GMT+05:30)
|
|
43
|
-
let tzAbbr
|
|
44
|
-
if (
|
|
45
|
-
const tz = momentDate.tz() || orgTimezone
|
|
43
|
+
let tzAbbr;
|
|
44
|
+
if (momentDate.isValid()) {
|
|
45
|
+
const tz = momentDate.tz() || orgTimezone;
|
|
46
46
|
tzAbbr = moment.tz.zone(tz)?.abbr(momentDate.valueOf()) || "UTC";
|
|
47
|
+
} else {
|
|
48
|
+
tzAbbr = "UTC"; // fallback
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
return `${momentDate.format(DATE_FORMAT)} ${tzAbbr}`;
|
|
@@ -64,6 +66,7 @@ export const formatDateWithTimezone = (date, orgTZ = false) => {
|
|
|
64
66
|
*/
|
|
65
67
|
export const getTimezoneTooltip = (date, orgTZ = false) => {
|
|
66
68
|
const orgTimezone = utilsLocalStorageApi.loadItem("orgTZ") || "Asia/Kolkata";
|
|
69
|
+
const serverTimezone = utilsLocalStorageApi.loadItem("serverTZ") || "Asia/Kolkata";
|
|
67
70
|
|
|
68
71
|
if(orgTZ){
|
|
69
72
|
return `Timezone: ${orgTimezone} (UTC${moment.tz(orgTimezone).format("Z")})`;
|
|
@@ -82,7 +85,7 @@ export const getTimezoneTooltip = (date, orgTZ = false) => {
|
|
|
82
85
|
if(!m.isValid() || m.isUTC()){
|
|
83
86
|
return `Timezone: ${orgTimezone} (UTC${moment.tz(orgTimezone).format("Z")})`; // fallback to orgTZ
|
|
84
87
|
}
|
|
85
|
-
return `Timezone: ${
|
|
88
|
+
return `Timezone: ${serverTimezone} (UTC${m.format("Z")})`; // return the timezone and offset
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
91
|
};
|