@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260418062449 → 0.8.1-dev.20260418064844

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/dist/index.js CHANGED
@@ -1153,6 +1153,7 @@ var DateView = (props) => {
1153
1153
  const getTimeZoneAbbreviation = (timeZone) => {
1154
1154
  return timeZoneAbbreviations[timeZone] || timeZone;
1155
1155
  };
1156
+ const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
1156
1157
  const getRelativeTime = (dateString) => {
1157
1158
  const now = /* @__PURE__ */ new Date();
1158
1159
  const date = new Date(
@@ -1173,55 +1174,7 @@ var DateView = (props) => {
1173
1174
  year: "numeric"
1174
1175
  }).format(date);
1175
1176
  };
1176
- console.log("DateView props:", props);
1177
- const getLocalDate = (value) => {
1178
- const now = /* @__PURE__ */ new Date();
1179
- const offsetMinutes = now.getTimezoneOffset();
1180
- const offsetMilliseconds = offsetMinutes * 60 * 1e3;
1181
- const valDate = value.toString().includes("Z") ? new Date(value) : /* @__PURE__ */ new Date(value + "Z");
1182
- return new Date(valDate.getTime() - offsetMilliseconds);
1183
- };
1184
- const parseAndFormatDate = (dateString, format) => {
1185
- const parsedDate = new Date(
1186
- dateString.includes("Z") ? dateString : dateString + "Z"
1187
- );
1188
- const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
1189
- if (format === "relative") {
1190
- return getRelativeTime(dateString);
1191
- }
1192
- switch (props.controlType) {
1193
- case "date":
1194
- return new Intl.DateTimeFormat("en", {
1195
- timeZone: userTimeZone,
1196
- day: "2-digit",
1197
- month: "short",
1198
- year: "numeric"
1199
- }).format(parsedDate);
1200
- case "time":
1201
- return `${formatTime(parsedDate)} ${getTimeZoneAbbreviation(
1202
- userTimeZone
1203
- )} (${getTimePeriod(parsedDate)})`;
1204
- default:
1205
- return parsedDate.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
1206
- timeZone: userTimeZone,
1207
- day: "2-digit",
1208
- month: "short",
1209
- year: "numeric",
1210
- hour: "2-digit",
1211
- minute: "2-digit"
1212
- }).format(parsedDate) : new Intl.DateTimeFormat("en", {
1213
- timeZone: userTimeZone,
1214
- day: "2-digit",
1215
- month: "short",
1216
- year: "numeric",
1217
- hour: "2-digit",
1218
- minute: "2-digit",
1219
- second: "2-digit"
1220
- }).format(parsedDate);
1221
- }
1222
- };
1223
1177
  const formatTime = (date) => {
1224
- const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
1225
1178
  return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
1226
1179
  timeZone: userTimeZone,
1227
1180
  hour: "2-digit",
@@ -1244,17 +1197,54 @@ var DateView = (props) => {
1244
1197
  if (hours >= 22 || hours < 5) return "Night";
1245
1198
  return "Late Night";
1246
1199
  };
1200
+ const parseAndFormatDate = (dateString, format) => {
1201
+ if (!dateString) return "";
1202
+ if (format === "relative") {
1203
+ return getRelativeTime(dateString);
1204
+ }
1205
+ const now = /* @__PURE__ */ new Date();
1206
+ const offsetMinutes = now.getTimezoneOffset();
1207
+ const offsetMilliseconds = offsetMinutes * 60 * 1e3;
1208
+ const valDate = dateString.includes("Z") ? new Date(dateString) : /* @__PURE__ */ new Date(dateString + "Z");
1209
+ const localDate = new Date(valDate.getTime() - offsetMilliseconds);
1210
+ if (props.controlType === "date") {
1211
+ return new Intl.DateTimeFormat("en", {
1212
+ day: "2-digit",
1213
+ month: "short",
1214
+ year: "numeric"
1215
+ }).format(localDate);
1216
+ }
1217
+ if (props.controlType === "time") {
1218
+ return `${formatTime(localDate)} ${getTimeZoneAbbreviation(
1219
+ userTimeZone
1220
+ )} (${getTimePeriod(localDate)})`;
1221
+ }
1222
+ return localDate.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
1223
+ day: "2-digit",
1224
+ month: "short",
1225
+ year: "numeric",
1226
+ hour: "2-digit",
1227
+ minute: "2-digit"
1228
+ }).format(localDate) : new Intl.DateTimeFormat("en", {
1229
+ day: "2-digit",
1230
+ month: "short",
1231
+ year: "numeric",
1232
+ hour: "2-digit",
1233
+ minute: "2-digit",
1234
+ second: "2-digit"
1235
+ }).format(localDate);
1236
+ };
1247
1237
  let localDateTime = "";
1248
1238
  let timeZoneAbbreviation = "";
1249
1239
  try {
1250
1240
  localDateTime = parseAndFormatDate(props.value, props.format);
1251
- timeZoneAbbreviation = getTimeZoneAbbreviation(Intl.DateTimeFormat().resolvedOptions().timeZone);
1241
+ timeZoneAbbreviation = getTimeZoneAbbreviation(userTimeZone);
1252
1242
  } catch (error) {
1253
1243
  console.error("Error parsing date:", props.value, error);
1254
1244
  }
1255
1245
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "inline-flex flex-wrap gap-1", children: [
1256
1246
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: localDateTime }),
1257
- !props.format && props.controlType != "date" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: timeZoneAbbreviation })
1247
+ !props.format && props.controlType !== "date" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: timeZoneAbbreviation })
1258
1248
  ] }) });
1259
1249
  };
1260
1250
  var DateView_default = DateView;
package/dist/index.mjs CHANGED
@@ -165,6 +165,7 @@ var DateView = (props) => {
165
165
  const getTimeZoneAbbreviation = (timeZone) => {
166
166
  return timeZoneAbbreviations[timeZone] || timeZone;
167
167
  };
168
+ const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
168
169
  const getRelativeTime = (dateString) => {
169
170
  const now = /* @__PURE__ */ new Date();
170
171
  const date = new Date(
@@ -185,55 +186,7 @@ var DateView = (props) => {
185
186
  year: "numeric"
186
187
  }).format(date);
187
188
  };
188
- console.log("DateView props:", props);
189
- const getLocalDate = (value) => {
190
- const now = /* @__PURE__ */ new Date();
191
- const offsetMinutes = now.getTimezoneOffset();
192
- const offsetMilliseconds = offsetMinutes * 60 * 1e3;
193
- const valDate = value.toString().includes("Z") ? new Date(value) : /* @__PURE__ */ new Date(value + "Z");
194
- return new Date(valDate.getTime() - offsetMilliseconds);
195
- };
196
- const parseAndFormatDate = (dateString, format) => {
197
- const parsedDate = new Date(
198
- dateString.includes("Z") ? dateString : dateString + "Z"
199
- );
200
- const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
201
- if (format === "relative") {
202
- return getRelativeTime(dateString);
203
- }
204
- switch (props.controlType) {
205
- case "date":
206
- return new Intl.DateTimeFormat("en", {
207
- timeZone: userTimeZone,
208
- day: "2-digit",
209
- month: "short",
210
- year: "numeric"
211
- }).format(parsedDate);
212
- case "time":
213
- return `${formatTime(parsedDate)} ${getTimeZoneAbbreviation(
214
- userTimeZone
215
- )} (${getTimePeriod(parsedDate)})`;
216
- default:
217
- return parsedDate.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
218
- timeZone: userTimeZone,
219
- day: "2-digit",
220
- month: "short",
221
- year: "numeric",
222
- hour: "2-digit",
223
- minute: "2-digit"
224
- }).format(parsedDate) : new Intl.DateTimeFormat("en", {
225
- timeZone: userTimeZone,
226
- day: "2-digit",
227
- month: "short",
228
- year: "numeric",
229
- hour: "2-digit",
230
- minute: "2-digit",
231
- second: "2-digit"
232
- }).format(parsedDate);
233
- }
234
- };
235
189
  const formatTime = (date) => {
236
- const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
237
190
  return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
238
191
  timeZone: userTimeZone,
239
192
  hour: "2-digit",
@@ -256,17 +209,54 @@ var DateView = (props) => {
256
209
  if (hours >= 22 || hours < 5) return "Night";
257
210
  return "Late Night";
258
211
  };
212
+ const parseAndFormatDate = (dateString, format) => {
213
+ if (!dateString) return "";
214
+ if (format === "relative") {
215
+ return getRelativeTime(dateString);
216
+ }
217
+ const now = /* @__PURE__ */ new Date();
218
+ const offsetMinutes = now.getTimezoneOffset();
219
+ const offsetMilliseconds = offsetMinutes * 60 * 1e3;
220
+ const valDate = dateString.includes("Z") ? new Date(dateString) : /* @__PURE__ */ new Date(dateString + "Z");
221
+ const localDate = new Date(valDate.getTime() - offsetMilliseconds);
222
+ if (props.controlType === "date") {
223
+ return new Intl.DateTimeFormat("en", {
224
+ day: "2-digit",
225
+ month: "short",
226
+ year: "numeric"
227
+ }).format(localDate);
228
+ }
229
+ if (props.controlType === "time") {
230
+ return `${formatTime(localDate)} ${getTimeZoneAbbreviation(
231
+ userTimeZone
232
+ )} (${getTimePeriod(localDate)})`;
233
+ }
234
+ return localDate.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
235
+ day: "2-digit",
236
+ month: "short",
237
+ year: "numeric",
238
+ hour: "2-digit",
239
+ minute: "2-digit"
240
+ }).format(localDate) : new Intl.DateTimeFormat("en", {
241
+ day: "2-digit",
242
+ month: "short",
243
+ year: "numeric",
244
+ hour: "2-digit",
245
+ minute: "2-digit",
246
+ second: "2-digit"
247
+ }).format(localDate);
248
+ };
259
249
  let localDateTime = "";
260
250
  let timeZoneAbbreviation = "";
261
251
  try {
262
252
  localDateTime = parseAndFormatDate(props.value, props.format);
263
- timeZoneAbbreviation = getTimeZoneAbbreviation(Intl.DateTimeFormat().resolvedOptions().timeZone);
253
+ timeZoneAbbreviation = getTimeZoneAbbreviation(userTimeZone);
264
254
  } catch (error) {
265
255
  console.error("Error parsing date:", props.value, error);
266
256
  }
267
257
  return /* @__PURE__ */ jsx2(React2.Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "inline-flex flex-wrap gap-1", children: [
268
258
  /* @__PURE__ */ jsx2("span", { children: localDateTime }),
269
- !props.format && props.controlType != "date" && /* @__PURE__ */ jsx2("span", { children: timeZoneAbbreviation })
259
+ !props.format && props.controlType !== "date" && /* @__PURE__ */ jsx2("span", { children: timeZoneAbbreviation })
270
260
  ] }) });
271
261
  };
272
262
  var DateView_default = DateView;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acoustte-digital-services/digitalstore-controls-dev",
3
- "version": "0.8.1-dev.20260418062449",
3
+ "version": "0.8.1-dev.20260418064844",
4
4
  "description": "Reusable React components",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",