@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260418061226 → 0.8.1-dev.20260418064017

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,40 +1174,62 @@ 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);
1177
+ const formatTime = (date) => {
1178
+ return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
1179
+ timeZone: userTimeZone,
1180
+ hour: "2-digit",
1181
+ minute: "2-digit"
1182
+ }).format(date) : new Intl.DateTimeFormat("en", {
1183
+ timeZone: userTimeZone,
1184
+ hour: "2-digit",
1185
+ minute: "2-digit",
1186
+ second: "2-digit"
1187
+ }).format(date);
1188
+ };
1189
+ const getTimePeriod = (date) => {
1190
+ const hours = date.getHours();
1191
+ if (hours >= 5 && hours < 8) return "Early Morning";
1192
+ if (hours >= 8 && hours < 12) return "Morning";
1193
+ if (hours >= 12 && hours < 14) return "Noon";
1194
+ if (hours >= 14 && hours < 17) return "Afternoon";
1195
+ if (hours >= 17 && hours < 20) return "Evening";
1196
+ if (hours >= 20 && hours < 22) return "Late Evening";
1197
+ if (hours >= 22 || hours < 5) return "Night";
1198
+ return "Late Night";
1183
1199
  };
1184
1200
  const parseAndFormatDate = (dateString, format) => {
1185
- const parsedDate = new Date(
1186
- dateString.includes("Z") ? dateString : dateString + "Z"
1187
- );
1201
+ if (!dateString) return "";
1188
1202
  if (format === "relative") {
1189
1203
  return getRelativeTime(dateString);
1190
1204
  }
1205
+ if (props.controlType === "date") {
1206
+ const datePart = dateString.split("T")[0];
1207
+ const [year, month, day] = datePart.split("-");
1208
+ const safeDate = new Date(Number(year), Number(month) - 1, Number(day));
1209
+ return new Intl.DateTimeFormat("en", {
1210
+ day: "2-digit",
1211
+ month: "short",
1212
+ year: "numeric"
1213
+ }).format(safeDate);
1214
+ }
1215
+ const parsedDate = new Date(
1216
+ dateString.includes("Z") ? dateString : dateString + "Z"
1217
+ );
1191
1218
  switch (props.controlType) {
1192
- case "date":
1193
- return new Intl.DateTimeFormat("en", {
1194
- day: "2-digit",
1195
- month: "short",
1196
- year: "numeric"
1197
- }).format(parsedDate);
1198
1219
  case "time":
1199
1220
  return `${formatTime(parsedDate)} ${getTimeZoneAbbreviation(
1200
- Intl.DateTimeFormat().resolvedOptions().timeZone
1221
+ userTimeZone
1201
1222
  )} (${getTimePeriod(parsedDate)})`;
1202
1223
  default:
1203
1224
  return parsedDate.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
1225
+ timeZone: userTimeZone,
1204
1226
  day: "2-digit",
1205
1227
  month: "short",
1206
1228
  year: "numeric",
1207
1229
  hour: "2-digit",
1208
1230
  minute: "2-digit"
1209
1231
  }).format(parsedDate) : new Intl.DateTimeFormat("en", {
1232
+ timeZone: userTimeZone,
1210
1233
  day: "2-digit",
1211
1234
  month: "short",
1212
1235
  year: "numeric",
@@ -1216,31 +1239,17 @@ var DateView = (props) => {
1216
1239
  }).format(parsedDate);
1217
1240
  }
1218
1241
  };
1219
- const formatTime = (date) => {
1220
- return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", { hour: "2-digit", minute: "2-digit" }).format(date) : new Intl.DateTimeFormat("en", { hour: "2-digit", minute: "2-digit", second: "2-digit" }).format(date);
1221
- };
1222
- const getTimePeriod = (date) => {
1223
- const hours = date.getHours();
1224
- if (hours >= 5 && hours < 8) return "Early Morning";
1225
- if (hours >= 8 && hours < 12) return "Morning";
1226
- if (hours >= 12 && hours < 14) return "Noon";
1227
- if (hours >= 14 && hours < 17) return "Afternoon";
1228
- if (hours >= 17 && hours < 20) return "Evening";
1229
- if (hours >= 20 && hours < 22) return "Late Evening";
1230
- if (hours >= 22 || hours < 5) return "Night";
1231
- return "Late Night";
1232
- };
1233
1242
  let localDateTime = "";
1234
1243
  let timeZoneAbbreviation = "";
1235
1244
  try {
1236
1245
  localDateTime = parseAndFormatDate(props.value, props.format);
1237
- timeZoneAbbreviation = getTimeZoneAbbreviation(Intl.DateTimeFormat().resolvedOptions().timeZone);
1246
+ timeZoneAbbreviation = getTimeZoneAbbreviation(userTimeZone);
1238
1247
  } catch (error) {
1239
1248
  console.error("Error parsing date:", props.value, error);
1240
1249
  }
1241
1250
  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: [
1242
1251
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: localDateTime }),
1243
- !props.format && props.controlType != "date" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: timeZoneAbbreviation })
1252
+ !props.format && props.controlType !== "date" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: timeZoneAbbreviation })
1244
1253
  ] }) });
1245
1254
  };
1246
1255
  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,40 +186,62 @@ 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);
189
+ const formatTime = (date) => {
190
+ return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
191
+ timeZone: userTimeZone,
192
+ hour: "2-digit",
193
+ minute: "2-digit"
194
+ }).format(date) : new Intl.DateTimeFormat("en", {
195
+ timeZone: userTimeZone,
196
+ hour: "2-digit",
197
+ minute: "2-digit",
198
+ second: "2-digit"
199
+ }).format(date);
200
+ };
201
+ const getTimePeriod = (date) => {
202
+ const hours = date.getHours();
203
+ if (hours >= 5 && hours < 8) return "Early Morning";
204
+ if (hours >= 8 && hours < 12) return "Morning";
205
+ if (hours >= 12 && hours < 14) return "Noon";
206
+ if (hours >= 14 && hours < 17) return "Afternoon";
207
+ if (hours >= 17 && hours < 20) return "Evening";
208
+ if (hours >= 20 && hours < 22) return "Late Evening";
209
+ if (hours >= 22 || hours < 5) return "Night";
210
+ return "Late Night";
195
211
  };
196
212
  const parseAndFormatDate = (dateString, format) => {
197
- const parsedDate = new Date(
198
- dateString.includes("Z") ? dateString : dateString + "Z"
199
- );
213
+ if (!dateString) return "";
200
214
  if (format === "relative") {
201
215
  return getRelativeTime(dateString);
202
216
  }
217
+ if (props.controlType === "date") {
218
+ const datePart = dateString.split("T")[0];
219
+ const [year, month, day] = datePart.split("-");
220
+ const safeDate = new Date(Number(year), Number(month) - 1, Number(day));
221
+ return new Intl.DateTimeFormat("en", {
222
+ day: "2-digit",
223
+ month: "short",
224
+ year: "numeric"
225
+ }).format(safeDate);
226
+ }
227
+ const parsedDate = new Date(
228
+ dateString.includes("Z") ? dateString : dateString + "Z"
229
+ );
203
230
  switch (props.controlType) {
204
- case "date":
205
- return new Intl.DateTimeFormat("en", {
206
- day: "2-digit",
207
- month: "short",
208
- year: "numeric"
209
- }).format(parsedDate);
210
231
  case "time":
211
232
  return `${formatTime(parsedDate)} ${getTimeZoneAbbreviation(
212
- Intl.DateTimeFormat().resolvedOptions().timeZone
233
+ userTimeZone
213
234
  )} (${getTimePeriod(parsedDate)})`;
214
235
  default:
215
236
  return parsedDate.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
237
+ timeZone: userTimeZone,
216
238
  day: "2-digit",
217
239
  month: "short",
218
240
  year: "numeric",
219
241
  hour: "2-digit",
220
242
  minute: "2-digit"
221
243
  }).format(parsedDate) : new Intl.DateTimeFormat("en", {
244
+ timeZone: userTimeZone,
222
245
  day: "2-digit",
223
246
  month: "short",
224
247
  year: "numeric",
@@ -228,31 +251,17 @@ var DateView = (props) => {
228
251
  }).format(parsedDate);
229
252
  }
230
253
  };
231
- const formatTime = (date) => {
232
- return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", { hour: "2-digit", minute: "2-digit" }).format(date) : new Intl.DateTimeFormat("en", { hour: "2-digit", minute: "2-digit", second: "2-digit" }).format(date);
233
- };
234
- const getTimePeriod = (date) => {
235
- const hours = date.getHours();
236
- if (hours >= 5 && hours < 8) return "Early Morning";
237
- if (hours >= 8 && hours < 12) return "Morning";
238
- if (hours >= 12 && hours < 14) return "Noon";
239
- if (hours >= 14 && hours < 17) return "Afternoon";
240
- if (hours >= 17 && hours < 20) return "Evening";
241
- if (hours >= 20 && hours < 22) return "Late Evening";
242
- if (hours >= 22 || hours < 5) return "Night";
243
- return "Late Night";
244
- };
245
254
  let localDateTime = "";
246
255
  let timeZoneAbbreviation = "";
247
256
  try {
248
257
  localDateTime = parseAndFormatDate(props.value, props.format);
249
- timeZoneAbbreviation = getTimeZoneAbbreviation(Intl.DateTimeFormat().resolvedOptions().timeZone);
258
+ timeZoneAbbreviation = getTimeZoneAbbreviation(userTimeZone);
250
259
  } catch (error) {
251
260
  console.error("Error parsing date:", props.value, error);
252
261
  }
253
262
  return /* @__PURE__ */ jsx2(React2.Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "inline-flex flex-wrap gap-1", children: [
254
263
  /* @__PURE__ */ jsx2("span", { children: localDateTime }),
255
- !props.format && props.controlType != "date" && /* @__PURE__ */ jsx2("span", { children: timeZoneAbbreviation })
264
+ !props.format && props.controlType !== "date" && /* @__PURE__ */ jsx2("span", { children: timeZoneAbbreviation })
256
265
  ] }) });
257
266
  };
258
267
  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.20260418061226",
3
+ "version": "0.8.1-dev.20260418064017",
4
4
  "description": "Reusable React components",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",