@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260427125546 → 0.8.1-dev.20260428110702
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 +37 -22
- package/dist/index.mjs +37 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1296,12 +1296,19 @@ var timeZoneAbbreviations = {
|
|
|
1296
1296
|
// src/components/controls/view/DateView.tsx
|
|
1297
1297
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1298
1298
|
var DateView = (props) => {
|
|
1299
|
+
const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1299
1300
|
const getTimeZoneAbbreviation = (timeZone) => {
|
|
1300
1301
|
return timeZoneAbbreviations[timeZone] || timeZone;
|
|
1301
1302
|
};
|
|
1303
|
+
const toUtcDate = (dateString) => {
|
|
1304
|
+
const s = dateString.trim();
|
|
1305
|
+
const iso = s.replace(" ", "T");
|
|
1306
|
+
const utc = iso.endsWith("Z") || iso.includes("+") ? iso : iso + "Z";
|
|
1307
|
+
return new Date(utc);
|
|
1308
|
+
};
|
|
1302
1309
|
const getRelativeTime = (dateString) => {
|
|
1303
1310
|
const now = /* @__PURE__ */ new Date();
|
|
1304
|
-
const date =
|
|
1311
|
+
const date = toUtcDate(dateString);
|
|
1305
1312
|
const diffMs = now.getTime() - date.getTime();
|
|
1306
1313
|
const diffSec = Math.floor(diffMs / 1e3);
|
|
1307
1314
|
const diffMin = Math.floor(diffSec / 60);
|
|
@@ -1314,12 +1321,12 @@ var DateView = (props) => {
|
|
|
1314
1321
|
return new Intl.DateTimeFormat("en", {
|
|
1315
1322
|
day: "2-digit",
|
|
1316
1323
|
month: "short",
|
|
1317
|
-
year: "numeric"
|
|
1324
|
+
year: "numeric",
|
|
1325
|
+
timeZone: userTimeZone
|
|
1318
1326
|
}).format(date);
|
|
1319
1327
|
};
|
|
1320
|
-
console.log("DateView props:", props);
|
|
1321
1328
|
const parseAndFormatDate = (dateString, format) => {
|
|
1322
|
-
const parsedDate =
|
|
1329
|
+
const parsedDate = toUtcDate(dateString);
|
|
1323
1330
|
if (format === "relative") {
|
|
1324
1331
|
return getRelativeTime(dateString);
|
|
1325
1332
|
}
|
|
@@ -1328,55 +1335,63 @@ var DateView = (props) => {
|
|
|
1328
1335
|
return new Intl.DateTimeFormat("en", {
|
|
1329
1336
|
day: "2-digit",
|
|
1330
1337
|
month: "short",
|
|
1331
|
-
year: "numeric"
|
|
1338
|
+
year: "numeric",
|
|
1339
|
+
timeZone: userTimeZone
|
|
1332
1340
|
}).format(parsedDate);
|
|
1333
1341
|
case "time":
|
|
1334
|
-
return `${formatTime(parsedDate)} ${getTimeZoneAbbreviation(
|
|
1342
|
+
return `${formatTime(parsedDate)} ${getTimeZoneAbbreviation(userTimeZone)} (${getTimePeriod(parsedDate)})`;
|
|
1335
1343
|
default:
|
|
1336
1344
|
return parsedDate.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
|
|
1337
1345
|
day: "2-digit",
|
|
1338
1346
|
month: "short",
|
|
1339
1347
|
year: "numeric",
|
|
1340
1348
|
hour: "2-digit",
|
|
1341
|
-
minute: "2-digit"
|
|
1349
|
+
minute: "2-digit",
|
|
1350
|
+
timeZone: userTimeZone
|
|
1342
1351
|
}).format(parsedDate) : new Intl.DateTimeFormat("en", {
|
|
1343
1352
|
day: "2-digit",
|
|
1344
1353
|
month: "short",
|
|
1345
1354
|
year: "numeric",
|
|
1346
1355
|
hour: "2-digit",
|
|
1347
1356
|
minute: "2-digit",
|
|
1348
|
-
second: "2-digit"
|
|
1357
|
+
second: "2-digit",
|
|
1358
|
+
timeZone: userTimeZone
|
|
1349
1359
|
}).format(parsedDate);
|
|
1350
1360
|
}
|
|
1351
1361
|
};
|
|
1352
1362
|
const formatTime = (date) => {
|
|
1353
1363
|
return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
|
|
1354
1364
|
hour: "2-digit",
|
|
1355
|
-
minute: "2-digit"
|
|
1365
|
+
minute: "2-digit",
|
|
1366
|
+
timeZone: userTimeZone
|
|
1356
1367
|
}).format(date) : new Intl.DateTimeFormat("en", {
|
|
1357
1368
|
hour: "2-digit",
|
|
1358
1369
|
minute: "2-digit",
|
|
1359
|
-
second: "2-digit"
|
|
1370
|
+
second: "2-digit",
|
|
1371
|
+
timeZone: userTimeZone
|
|
1360
1372
|
}).format(date);
|
|
1361
1373
|
};
|
|
1362
1374
|
const getTimePeriod = (date) => {
|
|
1363
|
-
const
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
if (
|
|
1371
|
-
return "
|
|
1375
|
+
const localHours = Number(
|
|
1376
|
+
new Intl.DateTimeFormat("en", {
|
|
1377
|
+
hour: "numeric",
|
|
1378
|
+
hour12: false,
|
|
1379
|
+
timeZone: userTimeZone
|
|
1380
|
+
}).format(date)
|
|
1381
|
+
);
|
|
1382
|
+
if (localHours >= 5 && localHours < 8) return "Early Morning";
|
|
1383
|
+
if (localHours >= 8 && localHours < 12) return "Morning";
|
|
1384
|
+
if (localHours >= 12 && localHours < 14) return "Noon";
|
|
1385
|
+
if (localHours >= 14 && localHours < 17) return "Afternoon";
|
|
1386
|
+
if (localHours >= 17 && localHours < 20) return "Evening";
|
|
1387
|
+
if (localHours >= 20 && localHours < 22) return "Late Evening";
|
|
1388
|
+
return "Night";
|
|
1372
1389
|
};
|
|
1373
1390
|
let localDateTime = "";
|
|
1374
1391
|
let timeZoneAbbreviation = "";
|
|
1375
1392
|
try {
|
|
1376
1393
|
localDateTime = parseAndFormatDate(props.value, props.format);
|
|
1377
|
-
timeZoneAbbreviation = getTimeZoneAbbreviation(
|
|
1378
|
-
Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
1379
|
-
);
|
|
1394
|
+
timeZoneAbbreviation = getTimeZoneAbbreviation(userTimeZone);
|
|
1380
1395
|
} catch (error) {
|
|
1381
1396
|
console.error("Error parsing date:", props.value, error);
|
|
1382
1397
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -164,12 +164,19 @@ var timeZoneAbbreviations = {
|
|
|
164
164
|
// src/components/controls/view/DateView.tsx
|
|
165
165
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
166
166
|
var DateView = (props) => {
|
|
167
|
+
const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
167
168
|
const getTimeZoneAbbreviation = (timeZone) => {
|
|
168
169
|
return timeZoneAbbreviations[timeZone] || timeZone;
|
|
169
170
|
};
|
|
171
|
+
const toUtcDate = (dateString) => {
|
|
172
|
+
const s = dateString.trim();
|
|
173
|
+
const iso = s.replace(" ", "T");
|
|
174
|
+
const utc = iso.endsWith("Z") || iso.includes("+") ? iso : iso + "Z";
|
|
175
|
+
return new Date(utc);
|
|
176
|
+
};
|
|
170
177
|
const getRelativeTime = (dateString) => {
|
|
171
178
|
const now = /* @__PURE__ */ new Date();
|
|
172
|
-
const date =
|
|
179
|
+
const date = toUtcDate(dateString);
|
|
173
180
|
const diffMs = now.getTime() - date.getTime();
|
|
174
181
|
const diffSec = Math.floor(diffMs / 1e3);
|
|
175
182
|
const diffMin = Math.floor(diffSec / 60);
|
|
@@ -182,12 +189,12 @@ var DateView = (props) => {
|
|
|
182
189
|
return new Intl.DateTimeFormat("en", {
|
|
183
190
|
day: "2-digit",
|
|
184
191
|
month: "short",
|
|
185
|
-
year: "numeric"
|
|
192
|
+
year: "numeric",
|
|
193
|
+
timeZone: userTimeZone
|
|
186
194
|
}).format(date);
|
|
187
195
|
};
|
|
188
|
-
console.log("DateView props:", props);
|
|
189
196
|
const parseAndFormatDate = (dateString, format) => {
|
|
190
|
-
const parsedDate =
|
|
197
|
+
const parsedDate = toUtcDate(dateString);
|
|
191
198
|
if (format === "relative") {
|
|
192
199
|
return getRelativeTime(dateString);
|
|
193
200
|
}
|
|
@@ -196,55 +203,63 @@ var DateView = (props) => {
|
|
|
196
203
|
return new Intl.DateTimeFormat("en", {
|
|
197
204
|
day: "2-digit",
|
|
198
205
|
month: "short",
|
|
199
|
-
year: "numeric"
|
|
206
|
+
year: "numeric",
|
|
207
|
+
timeZone: userTimeZone
|
|
200
208
|
}).format(parsedDate);
|
|
201
209
|
case "time":
|
|
202
|
-
return `${formatTime(parsedDate)} ${getTimeZoneAbbreviation(
|
|
210
|
+
return `${formatTime(parsedDate)} ${getTimeZoneAbbreviation(userTimeZone)} (${getTimePeriod(parsedDate)})`;
|
|
203
211
|
default:
|
|
204
212
|
return parsedDate.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
|
|
205
213
|
day: "2-digit",
|
|
206
214
|
month: "short",
|
|
207
215
|
year: "numeric",
|
|
208
216
|
hour: "2-digit",
|
|
209
|
-
minute: "2-digit"
|
|
217
|
+
minute: "2-digit",
|
|
218
|
+
timeZone: userTimeZone
|
|
210
219
|
}).format(parsedDate) : new Intl.DateTimeFormat("en", {
|
|
211
220
|
day: "2-digit",
|
|
212
221
|
month: "short",
|
|
213
222
|
year: "numeric",
|
|
214
223
|
hour: "2-digit",
|
|
215
224
|
minute: "2-digit",
|
|
216
|
-
second: "2-digit"
|
|
225
|
+
second: "2-digit",
|
|
226
|
+
timeZone: userTimeZone
|
|
217
227
|
}).format(parsedDate);
|
|
218
228
|
}
|
|
219
229
|
};
|
|
220
230
|
const formatTime = (date) => {
|
|
221
231
|
return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
|
|
222
232
|
hour: "2-digit",
|
|
223
|
-
minute: "2-digit"
|
|
233
|
+
minute: "2-digit",
|
|
234
|
+
timeZone: userTimeZone
|
|
224
235
|
}).format(date) : new Intl.DateTimeFormat("en", {
|
|
225
236
|
hour: "2-digit",
|
|
226
237
|
minute: "2-digit",
|
|
227
|
-
second: "2-digit"
|
|
238
|
+
second: "2-digit",
|
|
239
|
+
timeZone: userTimeZone
|
|
228
240
|
}).format(date);
|
|
229
241
|
};
|
|
230
242
|
const getTimePeriod = (date) => {
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (
|
|
239
|
-
return "
|
|
243
|
+
const localHours = Number(
|
|
244
|
+
new Intl.DateTimeFormat("en", {
|
|
245
|
+
hour: "numeric",
|
|
246
|
+
hour12: false,
|
|
247
|
+
timeZone: userTimeZone
|
|
248
|
+
}).format(date)
|
|
249
|
+
);
|
|
250
|
+
if (localHours >= 5 && localHours < 8) return "Early Morning";
|
|
251
|
+
if (localHours >= 8 && localHours < 12) return "Morning";
|
|
252
|
+
if (localHours >= 12 && localHours < 14) return "Noon";
|
|
253
|
+
if (localHours >= 14 && localHours < 17) return "Afternoon";
|
|
254
|
+
if (localHours >= 17 && localHours < 20) return "Evening";
|
|
255
|
+
if (localHours >= 20 && localHours < 22) return "Late Evening";
|
|
256
|
+
return "Night";
|
|
240
257
|
};
|
|
241
258
|
let localDateTime = "";
|
|
242
259
|
let timeZoneAbbreviation = "";
|
|
243
260
|
try {
|
|
244
261
|
localDateTime = parseAndFormatDate(props.value, props.format);
|
|
245
|
-
timeZoneAbbreviation = getTimeZoneAbbreviation(
|
|
246
|
-
Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
247
|
-
);
|
|
262
|
+
timeZoneAbbreviation = getTimeZoneAbbreviation(userTimeZone);
|
|
248
263
|
} catch (error) {
|
|
249
264
|
console.error("Error parsing date:", props.value, error);
|
|
250
265
|
}
|
package/package.json
CHANGED