@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capillarytech/cap-ui-utils",
3
- "version": "3.0.7-alpha.5",
3
+ "version": "3.0.7-alpha.7",
4
4
  "description": "Utility functions shared accross all the modules",
5
5
  "main": "index.js",
6
6
  "scripts": {
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 = momentDate.format("z");
44
- if (/GMT[+-]\d+/.test(tzAbbr)) {
45
- const tz = momentDate.tz() || orgTimezone || "UTC";
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: ${m.tz() || orgTimezone} (UTC${m.format("Z")})`; // return the timezone and offset
88
+ return `Timezone: ${serverTimezone} (UTC${m.format("Z")})`; // return the timezone and offset
86
89
  }
87
90
  }
88
91
  };