@fileverse-dev/formulajs 4.4.34 → 4.4.35
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/lib/browser/formula.js +24 -6
- package/lib/browser/formula.min.js +2 -2
- package/lib/browser/formula.min.js.map +1 -1
- package/lib/cjs/index.cjs +31 -170
- package/lib/esm/index.mjs +31 -170
- package/package.json +1 -1
- package/types/cjs/index.d.cts +3 -3
- package/types/esm/index.d.mts +3 -3
package/lib/cjs/index.cjs
CHANGED
|
@@ -8244,7 +8244,7 @@ function DATEVALUE(date_text) {
|
|
|
8244
8244
|
|
|
8245
8245
|
const dateValue = new Date(date_text);
|
|
8246
8246
|
|
|
8247
|
-
return
|
|
8247
|
+
return dateToSerial(dateValue);
|
|
8248
8248
|
}
|
|
8249
8249
|
|
|
8250
8250
|
/**
|
|
@@ -8440,169 +8440,10 @@ function EOMONTH(start_date, months) {
|
|
|
8440
8440
|
return returnSerial ? dateToSerial(eoMonth) : widthoutSerial
|
|
8441
8441
|
}
|
|
8442
8442
|
|
|
8443
|
-
// export function networkDaysIntl(startDate, endDate, weekend = 1, holidays = []) {
|
|
8444
|
-
// // Normalize input dates (strip time part)
|
|
8445
|
-
// const normalize = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
8446
|
-
// startDate = normalize(startDate);
|
|
8447
|
-
// endDate = normalize(endDate);
|
|
8448
|
-
|
|
8449
|
-
// // Google Sheets weekend mappings
|
|
8450
|
-
// const weekendMaps = {
|
|
8451
|
-
// 1: [6, 0], // Sat, Sun
|
|
8452
|
-
// 2: [0, 1], // Sun, Mon
|
|
8453
|
-
// 3: [1, 2], // Mon, Tue
|
|
8454
|
-
// 4: [2, 3], // Tue, Wed
|
|
8455
|
-
// 5: [3, 4], // Wed, Thu
|
|
8456
|
-
// 6: [4, 5], // Thu, Fri
|
|
8457
|
-
// 7: [5, 6], // Fri, Sat
|
|
8458
|
-
|
|
8459
|
-
// // Single-day weekend codes
|
|
8460
|
-
// 11: [0], // Sunday
|
|
8461
|
-
// 12: [1], // Monday
|
|
8462
|
-
// 13: [2], // Tuesday
|
|
8463
|
-
// 14: [3], // Wednesday
|
|
8464
|
-
// 15: [4], // Thursday
|
|
8465
|
-
// 16: [5], // Friday
|
|
8466
|
-
// 17: [6], // Saturday
|
|
8467
|
-
// };
|
|
8468
|
-
|
|
8469
|
-
// let weekendDays = [];
|
|
8470
|
-
|
|
8471
|
-
// // If weekend is a 7-char mask like "0000011"
|
|
8472
|
-
// if (typeof weekend === "string" && weekend.length === 7) {
|
|
8473
|
-
// weekendDays = weekend
|
|
8474
|
-
// .split("")
|
|
8475
|
-
// .map((ch, i) => (ch === "1" ? i : null))
|
|
8476
|
-
// .filter((v) => v !== null);
|
|
8477
|
-
// } else {
|
|
8478
|
-
// weekendDays = weekendMaps[weekend] || weekendMaps[1];
|
|
8479
|
-
// }
|
|
8480
|
-
|
|
8481
|
-
// // Normalize and convert holidays into timestamps
|
|
8482
|
-
// const holidaySet = new Set(
|
|
8483
|
-
// holidays.map((d) => normalize(d).getTime())
|
|
8484
|
-
// );
|
|
8485
|
-
|
|
8486
|
-
// let count = 0;
|
|
8487
|
-
// let current = new Date(startDate);
|
|
8488
|
-
|
|
8489
|
-
// while (current <= endDate) {
|
|
8490
|
-
// const day = current.getDay(); // 0=Sun ... 6=Sat
|
|
8491
|
-
// const ts = current.getTime();
|
|
8492
|
-
|
|
8493
|
-
// const isWeekend = weekendDays.includes(day);
|
|
8494
|
-
// const isHoliday = holidaySet.has(ts);
|
|
8495
|
-
|
|
8496
|
-
// if (!isWeekend && !isHoliday) {
|
|
8497
|
-
// count++;
|
|
8498
|
-
// }
|
|
8499
|
-
|
|
8500
|
-
// current.setDate(current.getDate() + 1);
|
|
8501
|
-
// }
|
|
8502
|
-
|
|
8503
|
-
// return count;
|
|
8504
|
-
// }
|
|
8505
|
-
|
|
8506
|
-
// export function networkDays(startDate, endDate, holidays = []) {
|
|
8507
|
-
// // Normalize date → remove time part
|
|
8508
|
-
// const normalize = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
8509
|
-
|
|
8510
|
-
// startDate = normalize(startDate);
|
|
8511
|
-
// endDate = normalize(endDate);
|
|
8512
|
-
|
|
8513
|
-
// // Convert holidays into a Set for O(1) lookup
|
|
8514
|
-
// const holidaySet = new Set(
|
|
8515
|
-
// holidays.map((d) => normalize(d).getTime())
|
|
8516
|
-
// );
|
|
8517
|
-
|
|
8518
|
-
// let count = 0;
|
|
8519
|
-
// let current = new Date(startDate);
|
|
8520
|
-
|
|
8521
|
-
// while (current <= endDate) {
|
|
8522
|
-
// const day = current.getDay(); // 0=Sun ... 6=Sat
|
|
8523
|
-
// const ts = current.getTime();
|
|
8524
|
-
|
|
8525
|
-
// const isWeekend = (day === 0 || day === 6); // Sun or Sat
|
|
8526
|
-
// const isHoliday = holidaySet.has(ts);
|
|
8527
|
-
|
|
8528
|
-
// if (!isWeekend && !isHoliday) {
|
|
8529
|
-
// count++;
|
|
8530
|
-
// }
|
|
8531
|
-
|
|
8532
|
-
// // move to next day
|
|
8533
|
-
// current.setDate(current.getDate() + 1);
|
|
8534
|
-
// }
|
|
8535
|
-
|
|
8536
|
-
// return count;
|
|
8537
|
-
// }
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
// export function workdayIntl(startDate, numDays, weekend = 1, holidays = []) {
|
|
8541
|
-
// // Normalize dates to midnight
|
|
8542
|
-
// const normalize = (d) =>
|
|
8543
|
-
// new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
8544
|
-
// startDate = normalize(startDate);
|
|
8545
|
-
|
|
8546
|
-
// // Weekend mapping from Google Sheets
|
|
8547
|
-
// const weekendMaps = {
|
|
8548
|
-
// 1: [6, 0], // Sat, Sun
|
|
8549
|
-
// 2: [0, 1], // Sun, Mon
|
|
8550
|
-
// 3: [1, 2], // Mon, Tue
|
|
8551
|
-
// 4: [2, 3], // Tue, Wed
|
|
8552
|
-
// 5: [3, 4], // Wed, Thu
|
|
8553
|
-
// 6: [4, 5], // Thu, Fri
|
|
8554
|
-
// 7: [5, 6], // Fri, Sat
|
|
8555
|
-
|
|
8556
|
-
// // Single-day weekend codes
|
|
8557
|
-
// 11: [0], // Sun
|
|
8558
|
-
// 12: [1], // Mon
|
|
8559
|
-
// 13: [2], // Tue
|
|
8560
|
-
// 14: [3], // Wed
|
|
8561
|
-
// 15: [4], // Thu
|
|
8562
|
-
// 16: [5], // Fri
|
|
8563
|
-
// 17: [6] // Sat
|
|
8564
|
-
// };
|
|
8565
|
-
|
|
8566
|
-
// let weekendDays = [];
|
|
8567
|
-
|
|
8568
|
-
// // If weekend is mask string like "0000011"
|
|
8569
|
-
// if (typeof weekend === "string" && weekend.length === 7) {
|
|
8570
|
-
// weekendDays = weekend
|
|
8571
|
-
// .split("")
|
|
8572
|
-
// .map((ch, i) => (ch === "1" ? i : null))
|
|
8573
|
-
// .filter((v) => v !== null);
|
|
8574
|
-
// } else {
|
|
8575
|
-
// weekendDays = weekendMaps[weekend] || weekendMaps[1];
|
|
8576
|
-
// }
|
|
8577
|
-
|
|
8578
|
-
// // Holidays → normalize → Set for fast lookup
|
|
8579
|
-
// const holidaySet = new Set(
|
|
8580
|
-
// holidays.map((h) => normalize(h).getTime())
|
|
8581
|
-
// );
|
|
8582
|
-
|
|
8583
|
-
// let current = new Date(startDate);
|
|
8584
|
-
// const direction = numDays >= 0 ? 1 : -1;
|
|
8585
|
-
|
|
8586
|
-
// let daysRemaining = Math.abs(numDays);
|
|
8587
|
-
|
|
8588
|
-
// while (daysRemaining > 0) {
|
|
8589
|
-
// current.setDate(current.getDate() + direction);
|
|
8590
|
-
|
|
8591
|
-
// const day = current.getDay();
|
|
8592
|
-
// const ts = current.getTime();
|
|
8593
|
-
|
|
8594
|
-
// const isWeekend = weekendDays.includes(day);
|
|
8595
|
-
// const isHoliday = holidaySet.has(ts);
|
|
8596
|
-
|
|
8597
|
-
// if (!isWeekend && !isHoliday) {
|
|
8598
|
-
// daysRemaining--;
|
|
8599
|
-
// }
|
|
8600
|
-
// }
|
|
8601
|
-
|
|
8602
|
-
// return current;
|
|
8603
|
-
// }
|
|
8604
|
-
|
|
8605
8443
|
function EPOCHTODATE(timestamp, timeUnit = 1) {
|
|
8444
|
+
if (isNaN(timestamp)) {
|
|
8445
|
+
return num;
|
|
8446
|
+
}
|
|
8606
8447
|
let ms;
|
|
8607
8448
|
|
|
8608
8449
|
switch (timeUnit) {
|
|
@@ -8622,7 +8463,18 @@ function EPOCHTODATE(timestamp, timeUnit = 1) {
|
|
|
8622
8463
|
throw new Error("Invalid time_unit. Use 1 (sec), 2 (ms), or 3 (µs).");
|
|
8623
8464
|
}
|
|
8624
8465
|
|
|
8625
|
-
|
|
8466
|
+
const d = new Date(ms);
|
|
8467
|
+
const pad = (n) => n.toString().padStart(2, "0");
|
|
8468
|
+
|
|
8469
|
+
const day = pad(d.getDate());
|
|
8470
|
+
const month = pad(d.getMonth() + 1);
|
|
8471
|
+
const year = d.getFullYear();
|
|
8472
|
+
|
|
8473
|
+
const hours = pad(d.getHours());
|
|
8474
|
+
const minutes = pad(d.getMinutes());
|
|
8475
|
+
const seconds = pad(d.getSeconds());
|
|
8476
|
+
|
|
8477
|
+
return `${day}/${month}/${year} ${hours}:${minutes}:${seconds}`
|
|
8626
8478
|
}
|
|
8627
8479
|
|
|
8628
8480
|
function SEQUENCE(rows, columns = 1, start = 1, step = 1) {
|
|
@@ -8632,7 +8484,14 @@ function SEQUENCE(rows, columns = 1, start = 1, step = 1) {
|
|
|
8632
8484
|
|
|
8633
8485
|
// Normalize date (remove time)
|
|
8634
8486
|
const normalizeDate = (d) =>
|
|
8635
|
-
new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
8487
|
+
new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
|
|
8488
|
+
|
|
8489
|
+
// Convert JS date → Google Sheets serial number
|
|
8490
|
+
const dateToSerial = (d) => {
|
|
8491
|
+
const utcDate = Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
|
|
8492
|
+
const gsEpoch = Date.UTC(1899, 11, 30); // Google Sheets epoch
|
|
8493
|
+
return (utcDate - gsEpoch) / (1000 * 60 * 60 * 24);
|
|
8494
|
+
};
|
|
8636
8495
|
|
|
8637
8496
|
if (isDate) start = normalizeDate(start);
|
|
8638
8497
|
|
|
@@ -8640,15 +8499,17 @@ function SEQUENCE(rows, columns = 1, start = 1, step = 1) {
|
|
|
8640
8499
|
const row = [];
|
|
8641
8500
|
|
|
8642
8501
|
for (let c = 0; c < columns; c++) {
|
|
8643
|
-
const index = r * columns + c;
|
|
8502
|
+
const index = r * columns + c;
|
|
8644
8503
|
|
|
8645
8504
|
if (isDate) {
|
|
8646
|
-
// Date sequence → step
|
|
8505
|
+
// Date sequence → step = days
|
|
8647
8506
|
const d = new Date(start);
|
|
8648
|
-
d.
|
|
8649
|
-
|
|
8507
|
+
d.setUTCDate(start.getUTCDate() + index * step);
|
|
8508
|
+
|
|
8509
|
+
// Return the DATEVALUE serial number instead of Date
|
|
8510
|
+
row.push(dateToSerial(d));
|
|
8650
8511
|
} else {
|
|
8651
|
-
//
|
|
8512
|
+
// Numeric sequence
|
|
8652
8513
|
row.push(start + index * step);
|
|
8653
8514
|
}
|
|
8654
8515
|
}
|
package/lib/esm/index.mjs
CHANGED
|
@@ -8242,7 +8242,7 @@ function DATEVALUE(date_text) {
|
|
|
8242
8242
|
|
|
8243
8243
|
const dateValue = new Date(date_text);
|
|
8244
8244
|
|
|
8245
|
-
return
|
|
8245
|
+
return dateToSerial(dateValue);
|
|
8246
8246
|
}
|
|
8247
8247
|
|
|
8248
8248
|
/**
|
|
@@ -8438,169 +8438,10 @@ function EOMONTH(start_date, months) {
|
|
|
8438
8438
|
return returnSerial ? dateToSerial(eoMonth) : widthoutSerial
|
|
8439
8439
|
}
|
|
8440
8440
|
|
|
8441
|
-
// export function networkDaysIntl(startDate, endDate, weekend = 1, holidays = []) {
|
|
8442
|
-
// // Normalize input dates (strip time part)
|
|
8443
|
-
// const normalize = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
8444
|
-
// startDate = normalize(startDate);
|
|
8445
|
-
// endDate = normalize(endDate);
|
|
8446
|
-
|
|
8447
|
-
// // Google Sheets weekend mappings
|
|
8448
|
-
// const weekendMaps = {
|
|
8449
|
-
// 1: [6, 0], // Sat, Sun
|
|
8450
|
-
// 2: [0, 1], // Sun, Mon
|
|
8451
|
-
// 3: [1, 2], // Mon, Tue
|
|
8452
|
-
// 4: [2, 3], // Tue, Wed
|
|
8453
|
-
// 5: [3, 4], // Wed, Thu
|
|
8454
|
-
// 6: [4, 5], // Thu, Fri
|
|
8455
|
-
// 7: [5, 6], // Fri, Sat
|
|
8456
|
-
|
|
8457
|
-
// // Single-day weekend codes
|
|
8458
|
-
// 11: [0], // Sunday
|
|
8459
|
-
// 12: [1], // Monday
|
|
8460
|
-
// 13: [2], // Tuesday
|
|
8461
|
-
// 14: [3], // Wednesday
|
|
8462
|
-
// 15: [4], // Thursday
|
|
8463
|
-
// 16: [5], // Friday
|
|
8464
|
-
// 17: [6], // Saturday
|
|
8465
|
-
// };
|
|
8466
|
-
|
|
8467
|
-
// let weekendDays = [];
|
|
8468
|
-
|
|
8469
|
-
// // If weekend is a 7-char mask like "0000011"
|
|
8470
|
-
// if (typeof weekend === "string" && weekend.length === 7) {
|
|
8471
|
-
// weekendDays = weekend
|
|
8472
|
-
// .split("")
|
|
8473
|
-
// .map((ch, i) => (ch === "1" ? i : null))
|
|
8474
|
-
// .filter((v) => v !== null);
|
|
8475
|
-
// } else {
|
|
8476
|
-
// weekendDays = weekendMaps[weekend] || weekendMaps[1];
|
|
8477
|
-
// }
|
|
8478
|
-
|
|
8479
|
-
// // Normalize and convert holidays into timestamps
|
|
8480
|
-
// const holidaySet = new Set(
|
|
8481
|
-
// holidays.map((d) => normalize(d).getTime())
|
|
8482
|
-
// );
|
|
8483
|
-
|
|
8484
|
-
// let count = 0;
|
|
8485
|
-
// let current = new Date(startDate);
|
|
8486
|
-
|
|
8487
|
-
// while (current <= endDate) {
|
|
8488
|
-
// const day = current.getDay(); // 0=Sun ... 6=Sat
|
|
8489
|
-
// const ts = current.getTime();
|
|
8490
|
-
|
|
8491
|
-
// const isWeekend = weekendDays.includes(day);
|
|
8492
|
-
// const isHoliday = holidaySet.has(ts);
|
|
8493
|
-
|
|
8494
|
-
// if (!isWeekend && !isHoliday) {
|
|
8495
|
-
// count++;
|
|
8496
|
-
// }
|
|
8497
|
-
|
|
8498
|
-
// current.setDate(current.getDate() + 1);
|
|
8499
|
-
// }
|
|
8500
|
-
|
|
8501
|
-
// return count;
|
|
8502
|
-
// }
|
|
8503
|
-
|
|
8504
|
-
// export function networkDays(startDate, endDate, holidays = []) {
|
|
8505
|
-
// // Normalize date → remove time part
|
|
8506
|
-
// const normalize = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
8507
|
-
|
|
8508
|
-
// startDate = normalize(startDate);
|
|
8509
|
-
// endDate = normalize(endDate);
|
|
8510
|
-
|
|
8511
|
-
// // Convert holidays into a Set for O(1) lookup
|
|
8512
|
-
// const holidaySet = new Set(
|
|
8513
|
-
// holidays.map((d) => normalize(d).getTime())
|
|
8514
|
-
// );
|
|
8515
|
-
|
|
8516
|
-
// let count = 0;
|
|
8517
|
-
// let current = new Date(startDate);
|
|
8518
|
-
|
|
8519
|
-
// while (current <= endDate) {
|
|
8520
|
-
// const day = current.getDay(); // 0=Sun ... 6=Sat
|
|
8521
|
-
// const ts = current.getTime();
|
|
8522
|
-
|
|
8523
|
-
// const isWeekend = (day === 0 || day === 6); // Sun or Sat
|
|
8524
|
-
// const isHoliday = holidaySet.has(ts);
|
|
8525
|
-
|
|
8526
|
-
// if (!isWeekend && !isHoliday) {
|
|
8527
|
-
// count++;
|
|
8528
|
-
// }
|
|
8529
|
-
|
|
8530
|
-
// // move to next day
|
|
8531
|
-
// current.setDate(current.getDate() + 1);
|
|
8532
|
-
// }
|
|
8533
|
-
|
|
8534
|
-
// return count;
|
|
8535
|
-
// }
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
// export function workdayIntl(startDate, numDays, weekend = 1, holidays = []) {
|
|
8539
|
-
// // Normalize dates to midnight
|
|
8540
|
-
// const normalize = (d) =>
|
|
8541
|
-
// new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
8542
|
-
// startDate = normalize(startDate);
|
|
8543
|
-
|
|
8544
|
-
// // Weekend mapping from Google Sheets
|
|
8545
|
-
// const weekendMaps = {
|
|
8546
|
-
// 1: [6, 0], // Sat, Sun
|
|
8547
|
-
// 2: [0, 1], // Sun, Mon
|
|
8548
|
-
// 3: [1, 2], // Mon, Tue
|
|
8549
|
-
// 4: [2, 3], // Tue, Wed
|
|
8550
|
-
// 5: [3, 4], // Wed, Thu
|
|
8551
|
-
// 6: [4, 5], // Thu, Fri
|
|
8552
|
-
// 7: [5, 6], // Fri, Sat
|
|
8553
|
-
|
|
8554
|
-
// // Single-day weekend codes
|
|
8555
|
-
// 11: [0], // Sun
|
|
8556
|
-
// 12: [1], // Mon
|
|
8557
|
-
// 13: [2], // Tue
|
|
8558
|
-
// 14: [3], // Wed
|
|
8559
|
-
// 15: [4], // Thu
|
|
8560
|
-
// 16: [5], // Fri
|
|
8561
|
-
// 17: [6] // Sat
|
|
8562
|
-
// };
|
|
8563
|
-
|
|
8564
|
-
// let weekendDays = [];
|
|
8565
|
-
|
|
8566
|
-
// // If weekend is mask string like "0000011"
|
|
8567
|
-
// if (typeof weekend === "string" && weekend.length === 7) {
|
|
8568
|
-
// weekendDays = weekend
|
|
8569
|
-
// .split("")
|
|
8570
|
-
// .map((ch, i) => (ch === "1" ? i : null))
|
|
8571
|
-
// .filter((v) => v !== null);
|
|
8572
|
-
// } else {
|
|
8573
|
-
// weekendDays = weekendMaps[weekend] || weekendMaps[1];
|
|
8574
|
-
// }
|
|
8575
|
-
|
|
8576
|
-
// // Holidays → normalize → Set for fast lookup
|
|
8577
|
-
// const holidaySet = new Set(
|
|
8578
|
-
// holidays.map((h) => normalize(h).getTime())
|
|
8579
|
-
// );
|
|
8580
|
-
|
|
8581
|
-
// let current = new Date(startDate);
|
|
8582
|
-
// const direction = numDays >= 0 ? 1 : -1;
|
|
8583
|
-
|
|
8584
|
-
// let daysRemaining = Math.abs(numDays);
|
|
8585
|
-
|
|
8586
|
-
// while (daysRemaining > 0) {
|
|
8587
|
-
// current.setDate(current.getDate() + direction);
|
|
8588
|
-
|
|
8589
|
-
// const day = current.getDay();
|
|
8590
|
-
// const ts = current.getTime();
|
|
8591
|
-
|
|
8592
|
-
// const isWeekend = weekendDays.includes(day);
|
|
8593
|
-
// const isHoliday = holidaySet.has(ts);
|
|
8594
|
-
|
|
8595
|
-
// if (!isWeekend && !isHoliday) {
|
|
8596
|
-
// daysRemaining--;
|
|
8597
|
-
// }
|
|
8598
|
-
// }
|
|
8599
|
-
|
|
8600
|
-
// return current;
|
|
8601
|
-
// }
|
|
8602
|
-
|
|
8603
8441
|
function EPOCHTODATE(timestamp, timeUnit = 1) {
|
|
8442
|
+
if (isNaN(timestamp)) {
|
|
8443
|
+
return num;
|
|
8444
|
+
}
|
|
8604
8445
|
let ms;
|
|
8605
8446
|
|
|
8606
8447
|
switch (timeUnit) {
|
|
@@ -8620,7 +8461,18 @@ function EPOCHTODATE(timestamp, timeUnit = 1) {
|
|
|
8620
8461
|
throw new Error("Invalid time_unit. Use 1 (sec), 2 (ms), or 3 (µs).");
|
|
8621
8462
|
}
|
|
8622
8463
|
|
|
8623
|
-
|
|
8464
|
+
const d = new Date(ms);
|
|
8465
|
+
const pad = (n) => n.toString().padStart(2, "0");
|
|
8466
|
+
|
|
8467
|
+
const day = pad(d.getDate());
|
|
8468
|
+
const month = pad(d.getMonth() + 1);
|
|
8469
|
+
const year = d.getFullYear();
|
|
8470
|
+
|
|
8471
|
+
const hours = pad(d.getHours());
|
|
8472
|
+
const minutes = pad(d.getMinutes());
|
|
8473
|
+
const seconds = pad(d.getSeconds());
|
|
8474
|
+
|
|
8475
|
+
return `${day}/${month}/${year} ${hours}:${minutes}:${seconds}`
|
|
8624
8476
|
}
|
|
8625
8477
|
|
|
8626
8478
|
function SEQUENCE(rows, columns = 1, start = 1, step = 1) {
|
|
@@ -8630,7 +8482,14 @@ function SEQUENCE(rows, columns = 1, start = 1, step = 1) {
|
|
|
8630
8482
|
|
|
8631
8483
|
// Normalize date (remove time)
|
|
8632
8484
|
const normalizeDate = (d) =>
|
|
8633
|
-
new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
8485
|
+
new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
|
|
8486
|
+
|
|
8487
|
+
// Convert JS date → Google Sheets serial number
|
|
8488
|
+
const dateToSerial = (d) => {
|
|
8489
|
+
const utcDate = Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
|
|
8490
|
+
const gsEpoch = Date.UTC(1899, 11, 30); // Google Sheets epoch
|
|
8491
|
+
return (utcDate - gsEpoch) / (1000 * 60 * 60 * 24);
|
|
8492
|
+
};
|
|
8634
8493
|
|
|
8635
8494
|
if (isDate) start = normalizeDate(start);
|
|
8636
8495
|
|
|
@@ -8638,15 +8497,17 @@ function SEQUENCE(rows, columns = 1, start = 1, step = 1) {
|
|
|
8638
8497
|
const row = [];
|
|
8639
8498
|
|
|
8640
8499
|
for (let c = 0; c < columns; c++) {
|
|
8641
|
-
const index = r * columns + c;
|
|
8500
|
+
const index = r * columns + c;
|
|
8642
8501
|
|
|
8643
8502
|
if (isDate) {
|
|
8644
|
-
// Date sequence → step
|
|
8503
|
+
// Date sequence → step = days
|
|
8645
8504
|
const d = new Date(start);
|
|
8646
|
-
d.
|
|
8647
|
-
|
|
8505
|
+
d.setUTCDate(start.getUTCDate() + index * step);
|
|
8506
|
+
|
|
8507
|
+
// Return the DATEVALUE serial number instead of Date
|
|
8508
|
+
row.push(dateToSerial(d));
|
|
8648
8509
|
} else {
|
|
8649
|
-
//
|
|
8510
|
+
// Numeric sequence
|
|
8650
8511
|
row.push(start + index * step);
|
|
8651
8512
|
}
|
|
8652
8513
|
}
|
package/package.json
CHANGED
package/types/cjs/index.d.cts
CHANGED
|
@@ -1057,7 +1057,7 @@ declare function DATEDIF(start_date: any, end_date: any, unit: any): number | Er
|
|
|
1057
1057
|
* @param {*} date_text Text that represents a date in an Excel date format, or a reference to a value that contains text that represents a date in an Excel date format.
|
|
1058
1058
|
* @returns
|
|
1059
1059
|
*/
|
|
1060
|
-
declare function DATEVALUE(date_text: any): number | Error
|
|
1060
|
+
declare function DATEVALUE(date_text: any): number | Error;
|
|
1061
1061
|
/**
|
|
1062
1062
|
* Returns the average of selected database entries.
|
|
1063
1063
|
*
|
|
@@ -1426,7 +1426,7 @@ declare function EOA(...args: any[]): Promise<any>;
|
|
|
1426
1426
|
* @returns
|
|
1427
1427
|
*/
|
|
1428
1428
|
declare function EOMONTH(start_date: any, months: any): number | Error | Date;
|
|
1429
|
-
declare function EPOCHTODATE(timestamp: any, timeUnit?: number):
|
|
1429
|
+
declare function EPOCHTODATE(timestamp: any, timeUnit?: number): string | Error;
|
|
1430
1430
|
/**
|
|
1431
1431
|
* Returns the error function.
|
|
1432
1432
|
*
|
|
@@ -3761,7 +3761,7 @@ declare function SECH(number: any): number | Error;
|
|
|
3761
3761
|
* @returns
|
|
3762
3762
|
*/
|
|
3763
3763
|
declare function SECOND(serial_number: any): any;
|
|
3764
|
-
declare function SEQUENCE(rows: any, columns?: number, start?: number, step?: number):
|
|
3764
|
+
declare function SEQUENCE(rows: any, columns?: number, start?: number, step?: number): number[][];
|
|
3765
3765
|
/**
|
|
3766
3766
|
* Returns the sum of a power series based on the formula.
|
|
3767
3767
|
*
|
package/types/esm/index.d.mts
CHANGED
|
@@ -996,7 +996,7 @@ export function DATEDIF(start_date: any, end_date: any, unit: any): number | Err
|
|
|
996
996
|
* @param {*} date_text Text that represents a date in an Excel date format, or a reference to a value that contains text that represents a date in an Excel date format.
|
|
997
997
|
* @returns
|
|
998
998
|
*/
|
|
999
|
-
export function DATEVALUE(date_text: any): number | Error
|
|
999
|
+
export function DATEVALUE(date_text: any): number | Error;
|
|
1000
1000
|
/**
|
|
1001
1001
|
* Returns the average of selected database entries.
|
|
1002
1002
|
*
|
|
@@ -1365,7 +1365,7 @@ export function EOA(...args: any[]): Promise<any>;
|
|
|
1365
1365
|
* @returns
|
|
1366
1366
|
*/
|
|
1367
1367
|
export function EOMONTH(start_date: any, months: any): number | Error | Date;
|
|
1368
|
-
export function EPOCHTODATE(timestamp: any, timeUnit?: number):
|
|
1368
|
+
export function EPOCHTODATE(timestamp: any, timeUnit?: number): string | Error;
|
|
1369
1369
|
/**
|
|
1370
1370
|
* Returns the error function.
|
|
1371
1371
|
*
|
|
@@ -3700,7 +3700,7 @@ export function SECH(number: any): number | Error;
|
|
|
3700
3700
|
* @returns
|
|
3701
3701
|
*/
|
|
3702
3702
|
export function SECOND(serial_number: any): any;
|
|
3703
|
-
export function SEQUENCE(rows: any, columns?: number, start?: number, step?: number):
|
|
3703
|
+
export function SEQUENCE(rows: any, columns?: number, start?: number, step?: number): number[][];
|
|
3704
3704
|
/**
|
|
3705
3705
|
* Returns the sum of a power series based on the formula.
|
|
3706
3706
|
*
|