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/cjs/index.js
CHANGED
|
@@ -16398,7 +16398,7 @@ const getWordCount = (text) => {
|
|
|
16398
16398
|
* @returns Timestamp in milliseconds since epoch
|
|
16399
16399
|
*/
|
|
16400
16400
|
const getTimestampFromTimeInfoInET = (opts) => {
|
|
16401
|
-
var _a, _b, _c, _d, _e, _f;
|
|
16401
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
16402
16402
|
// Destructure opts
|
|
16403
16403
|
const { year, month, day, hour, minute, } = opts;
|
|
16404
16404
|
// Format with leading zeroes
|
|
@@ -16406,7 +16406,7 @@ const getTimestampFromTimeInfoInET = (opts) => {
|
|
|
16406
16406
|
const dd = padZerosLeft(day, 2);
|
|
16407
16407
|
const hh = padZerosLeft(hour, 2);
|
|
16408
16408
|
const min = padZerosLeft(minute, 2);
|
|
16409
|
-
// Use Intl.DateTimeFormat to get the ET offset
|
|
16409
|
+
// Use Intl.DateTimeFormat to get the ET offset and ET components
|
|
16410
16410
|
const dateForET = new Date(Date.UTC(year, month - 1, day, hour, minute, 0));
|
|
16411
16411
|
const options = {
|
|
16412
16412
|
timeZone: 'America/New_York',
|
|
@@ -16417,6 +16417,7 @@ const getTimestampFromTimeInfoInET = (opts) => {
|
|
|
16417
16417
|
minute: '2-digit',
|
|
16418
16418
|
second: '2-digit',
|
|
16419
16419
|
hour12: false,
|
|
16420
|
+
timeZoneName: 'shortOffset',
|
|
16420
16421
|
};
|
|
16421
16422
|
const parts = new Intl.DateTimeFormat('en-US', options).formatToParts(dateForET);
|
|
16422
16423
|
const etYear = (_a = parts.find((p) => {
|
|
@@ -16437,11 +16438,20 @@ const getTimestampFromTimeInfoInET = (opts) => {
|
|
|
16437
16438
|
const etSecond = (_f = parts.find((p) => {
|
|
16438
16439
|
return p.type === 'second';
|
|
16439
16440
|
})) === null || _f === void 0 ? void 0 : _f.value;
|
|
16440
|
-
|
|
16441
|
-
|
|
16441
|
+
const tzName = (_g = parts.find((p) => {
|
|
16442
|
+
return p.type === 'timeZoneName';
|
|
16443
|
+
})) === null || _g === void 0 ? void 0 : _g.value;
|
|
16444
|
+
// Validate we got everything we need
|
|
16445
|
+
if (!etYear || !etMonth || !etDay || !etHour || !etMinute || !etSecond || !tzName) {
|
|
16442
16446
|
throw new ErrorWithCode('Failed to parse date parts from Intl.DateTimeFormat', ReactKitErrorCode$1.ETTimestampInvalid);
|
|
16443
16447
|
}
|
|
16444
|
-
|
|
16448
|
+
// Extract numeric offset from "GMT-4" or "UTC-5"
|
|
16449
|
+
const offsetNum = Number(tzName.replace(/^(GMT|UTC)/, ''));
|
|
16450
|
+
const sign = offsetNum >= 0 ? '+' : '-';
|
|
16451
|
+
const offset = `${sign}${padZerosLeft(Math.abs(offsetNum), 2)}:00`;
|
|
16452
|
+
// Build ISO string with offset
|
|
16453
|
+
const etDateString = `${etYear}-${etMonth}-${etDay}T${etHour}:${etMinute}:${etSecond}${offset}`;
|
|
16454
|
+
// Parse into ET timestamp
|
|
16445
16455
|
const etDate = new Date(etDateString);
|
|
16446
16456
|
const timestamp = etDate.getTime();
|
|
16447
16457
|
// Verify that the timestamp is correct
|
|
@@ -16451,7 +16461,9 @@ const getTimestampFromTimeInfoInET = (opts) => {
|
|
|
16451
16461
|
|| timeInfoInET.day !== day
|
|
16452
16462
|
|| timeInfoInET.hour !== hour
|
|
16453
16463
|
|| timeInfoInET.minute !== minute) {
|
|
16454
|
-
throw new ErrorWithCode(`Timestamp mismatch: expected ${year}-${mm}-${dd} ${hh}:${min},
|
|
16464
|
+
throw new ErrorWithCode(`Timestamp mismatch: expected ${year}-${mm}-${dd} ${hh}:${min}, `
|
|
16465
|
+
+ `got ${timeInfoInET.year}-${padZerosLeft(timeInfoInET.month, 2)}-${padZerosLeft(timeInfoInET.day, 2)} `
|
|
16466
|
+
+ `${padZerosLeft(timeInfoInET.hour, 2)}:${padZerosLeft(timeInfoInET.minute, 2)}`, ReactKitErrorCode$1.ETTimestampInvalid);
|
|
16455
16467
|
}
|
|
16456
16468
|
// Valid! Return the timestamp
|
|
16457
16469
|
return timestamp;
|