@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/utils/timezone.js +17 -20
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capillarytech/cap-ui-utils",
3
- "version": "3.0.7-alpha.3",
3
+ "version": "3.0.7-alpha.5",
4
4
  "description": "Utility functions shared accross all the modules",
5
5
  "main": "index.js",
6
6
  "scripts": {
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
- // Case 1: Epoch number or numeric string
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
- // Case 3: Try parsing ISO or custom string
79
- let m = moment.parseZone(date); // handles ISO strings like 2025-08-12T23:59:59.000Z
80
-
81
- if (!m.isValid()) {
82
- m = moment.tz(date, "DD MMM YYYY h:mm A z");
83
- }
84
-
85
- // If still invalid → fallback to orgTZ
86
- if (!m.isValid()) {
87
- return `Timezone: ${orgTimezone} (UTC${moment.tz(orgTimezone).format("Z")})`;
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
  };