dce-reactkit 4.2.4-beta-timestamp.1 → 4.2.4-beta-timestamp.2
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/esm/index.js
CHANGED
|
@@ -16371,7 +16371,7 @@ const getWordCount = (text) => {
|
|
|
16371
16371
|
* @returns Timestamp in milliseconds since epoch
|
|
16372
16372
|
*/
|
|
16373
16373
|
const getTimestampFromTimeInfoInET = (opts) => {
|
|
16374
|
-
var _a, _b, _c, _d, _e, _f;
|
|
16374
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
16375
16375
|
// Destructure opts
|
|
16376
16376
|
const { year, month, day, hour, minute, } = opts;
|
|
16377
16377
|
// Format with leading zeroes
|
|
@@ -16379,7 +16379,7 @@ const getTimestampFromTimeInfoInET = (opts) => {
|
|
|
16379
16379
|
const dd = padZerosLeft(day, 2);
|
|
16380
16380
|
const hh = padZerosLeft(hour, 2);
|
|
16381
16381
|
const min = padZerosLeft(minute, 2);
|
|
16382
|
-
// Use Intl.DateTimeFormat to get the ET offset
|
|
16382
|
+
// Use Intl.DateTimeFormat to get the ET offset and ET components
|
|
16383
16383
|
const dateForET = new Date(Date.UTC(year, month - 1, day, hour, minute, 0));
|
|
16384
16384
|
const options = {
|
|
16385
16385
|
timeZone: 'America/New_York',
|
|
@@ -16390,6 +16390,7 @@ const getTimestampFromTimeInfoInET = (opts) => {
|
|
|
16390
16390
|
minute: '2-digit',
|
|
16391
16391
|
second: '2-digit',
|
|
16392
16392
|
hour12: false,
|
|
16393
|
+
timeZoneName: 'shortOffset',
|
|
16393
16394
|
};
|
|
16394
16395
|
const parts = new Intl.DateTimeFormat('en-US', options).formatToParts(dateForET);
|
|
16395
16396
|
const etYear = (_a = parts.find((p) => {
|
|
@@ -16410,11 +16411,20 @@ const getTimestampFromTimeInfoInET = (opts) => {
|
|
|
16410
16411
|
const etSecond = (_f = parts.find((p) => {
|
|
16411
16412
|
return p.type === 'second';
|
|
16412
16413
|
})) === null || _f === void 0 ? void 0 : _f.value;
|
|
16413
|
-
|
|
16414
|
-
|
|
16414
|
+
const tzName = (_g = parts.find((p) => {
|
|
16415
|
+
return p.type === 'timeZoneName';
|
|
16416
|
+
})) === null || _g === void 0 ? void 0 : _g.value;
|
|
16417
|
+
// Validate we got everything we need
|
|
16418
|
+
if (!etYear || !etMonth || !etDay || !etHour || !etMinute || !etSecond || !tzName) {
|
|
16415
16419
|
throw new ErrorWithCode('Failed to parse date parts from Intl.DateTimeFormat', ReactKitErrorCode$1.ETTimestampInvalid);
|
|
16416
16420
|
}
|
|
16417
|
-
|
|
16421
|
+
// Extract numeric offset from "GMT-4" or "UTC-5"
|
|
16422
|
+
const offsetNum = Number(tzName.replace(/^(GMT|UTC)/, ''));
|
|
16423
|
+
const sign = offsetNum >= 0 ? '+' : '-';
|
|
16424
|
+
const offset = `${sign}${padZerosLeft(Math.abs(offsetNum), 2)}:00`;
|
|
16425
|
+
// Build ISO string with offset
|
|
16426
|
+
const etDateString = `${etYear}-${etMonth}-${etDay}T${etHour}:${etMinute}:${etSecond}${offset}`;
|
|
16427
|
+
// Parse into ET timestamp
|
|
16418
16428
|
const etDate = new Date(etDateString);
|
|
16419
16429
|
const timestamp = etDate.getTime();
|
|
16420
16430
|
// Verify that the timestamp is correct
|
|
@@ -16424,7 +16434,9 @@ const getTimestampFromTimeInfoInET = (opts) => {
|
|
|
16424
16434
|
|| timeInfoInET.day !== day
|
|
16425
16435
|
|| timeInfoInET.hour !== hour
|
|
16426
16436
|
|| timeInfoInET.minute !== minute) {
|
|
16427
|
-
throw new ErrorWithCode(`Timestamp mismatch: expected ${year}-${mm}-${dd} ${hh}:${min},
|
|
16437
|
+
throw new ErrorWithCode(`Timestamp mismatch: expected ${year}-${mm}-${dd} ${hh}:${min}, `
|
|
16438
|
+
+ `got ${timeInfoInET.year}-${padZerosLeft(timeInfoInET.month, 2)}-${padZerosLeft(timeInfoInET.day, 2)} `
|
|
16439
|
+
+ `${padZerosLeft(timeInfoInET.hour, 2)}:${padZerosLeft(timeInfoInET.minute, 2)}`, ReactKitErrorCode$1.ETTimestampInvalid);
|
|
16428
16440
|
}
|
|
16429
16441
|
// Valid! Return the timestamp
|
|
16430
16442
|
return timestamp;
|