@fileverse-dev/formulajs 4.4.33 → 4.4.34

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/cjs/index.cjs CHANGED
@@ -8440,169 +8440,169 @@ function EOMONTH(start_date, months) {
8440
8440
  return returnSerial ? dateToSerial(eoMonth) : widthoutSerial
8441
8441
  }
8442
8442
 
8443
- 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
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
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);
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
+ // }
8488
8480
 
8489
- while (current <= endDate) {
8490
- const day = current.getDay(); // 0=Sun ... 6=Sat
8491
- const ts = current.getTime();
8481
+ // // Normalize and convert holidays into timestamps
8482
+ // const holidaySet = new Set(
8483
+ // holidays.map((d) => normalize(d).getTime())
8484
+ // );
8492
8485
 
8493
- const isWeekend = weekendDays.includes(day);
8494
- const isHoliday = holidaySet.has(ts);
8486
+ // let count = 0;
8487
+ // let current = new Date(startDate);
8495
8488
 
8496
- if (!isWeekend && !isHoliday) {
8497
- count++;
8498
- }
8489
+ // while (current <= endDate) {
8490
+ // const day = current.getDay(); // 0=Sun ... 6=Sat
8491
+ // const ts = current.getTime();
8499
8492
 
8500
- current.setDate(current.getDate() + 1);
8501
- }
8493
+ // const isWeekend = weekendDays.includes(day);
8494
+ // const isHoliday = holidaySet.has(ts);
8502
8495
 
8503
- return count;
8504
- }
8496
+ // if (!isWeekend && !isHoliday) {
8497
+ // count++;
8498
+ // }
8505
8499
 
8506
- function networkDays(startDate, endDate, holidays = []) {
8507
- // Normalize date → remove time part
8508
- const normalize = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
8500
+ // current.setDate(current.getDate() + 1);
8501
+ // }
8509
8502
 
8510
- startDate = normalize(startDate);
8511
- endDate = normalize(endDate);
8503
+ // return count;
8504
+ // }
8512
8505
 
8513
- // Convert holidays into a Set for O(1) lookup
8514
- const holidaySet = new Set(
8515
- holidays.map((d) => normalize(d).getTime())
8516
- );
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());
8517
8509
 
8518
- let count = 0;
8519
- let current = new Date(startDate);
8510
+ // startDate = normalize(startDate);
8511
+ // endDate = normalize(endDate);
8520
8512
 
8521
- while (current <= endDate) {
8522
- const day = current.getDay(); // 0=Sun ... 6=Sat
8523
- const ts = current.getTime();
8513
+ // // Convert holidays into a Set for O(1) lookup
8514
+ // const holidaySet = new Set(
8515
+ // holidays.map((d) => normalize(d).getTime())
8516
+ // );
8524
8517
 
8525
- const isWeekend = (day === 0 || day === 6); // Sun or Sat
8526
- const isHoliday = holidaySet.has(ts);
8518
+ // let count = 0;
8519
+ // let current = new Date(startDate);
8527
8520
 
8528
- if (!isWeekend && !isHoliday) {
8529
- count++;
8530
- }
8521
+ // while (current <= endDate) {
8522
+ // const day = current.getDay(); // 0=Sun ... 6=Sat
8523
+ // const ts = current.getTime();
8531
8524
 
8532
- // move to next day
8533
- current.setDate(current.getDate() + 1);
8534
- }
8525
+ // const isWeekend = (day === 0 || day === 6); // Sun or Sat
8526
+ // const isHoliday = holidaySet.has(ts);
8535
8527
 
8536
- return count;
8537
- }
8528
+ // if (!isWeekend && !isHoliday) {
8529
+ // count++;
8530
+ // }
8538
8531
 
8532
+ // // move to next day
8533
+ // current.setDate(current.getDate() + 1);
8534
+ // }
8539
8535
 
8540
- 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
- };
8536
+ // return count;
8537
+ // }
8565
8538
 
8566
- let weekendDays = [];
8567
8539
 
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
- }
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
8577
 
8578
- // Holidays → normalize → Set for fast lookup
8579
- const holidaySet = new Set(
8580
- holidays.map((h) => normalize(h).getTime())
8581
- );
8578
+ // // Holidays → normalize → Set for fast lookup
8579
+ // const holidaySet = new Set(
8580
+ // holidays.map((h) => normalize(h).getTime())
8581
+ // );
8582
8582
 
8583
- let current = new Date(startDate);
8584
- const direction = numDays >= 0 ? 1 : -1;
8583
+ // let current = new Date(startDate);
8584
+ // const direction = numDays >= 0 ? 1 : -1;
8585
8585
 
8586
- let daysRemaining = Math.abs(numDays);
8586
+ // let daysRemaining = Math.abs(numDays);
8587
8587
 
8588
- while (daysRemaining > 0) {
8589
- current.setDate(current.getDate() + direction);
8588
+ // while (daysRemaining > 0) {
8589
+ // current.setDate(current.getDate() + direction);
8590
8590
 
8591
- const day = current.getDay();
8592
- const ts = current.getTime();
8591
+ // const day = current.getDay();
8592
+ // const ts = current.getTime();
8593
8593
 
8594
- const isWeekend = weekendDays.includes(day);
8595
- const isHoliday = holidaySet.has(ts);
8594
+ // const isWeekend = weekendDays.includes(day);
8595
+ // const isHoliday = holidaySet.has(ts);
8596
8596
 
8597
- if (!isWeekend && !isHoliday) {
8598
- daysRemaining--;
8599
- }
8600
- }
8597
+ // if (!isWeekend && !isHoliday) {
8598
+ // daysRemaining--;
8599
+ // }
8600
+ // }
8601
8601
 
8602
- return current;
8603
- }
8602
+ // return current;
8603
+ // }
8604
8604
 
8605
- function epochToDate(timestamp, timeUnit = 1) {
8605
+ function EPOCHTODATE(timestamp, timeUnit = 1) {
8606
8606
  let ms;
8607
8607
 
8608
8608
  switch (timeUnit) {
@@ -8625,7 +8625,7 @@ function epochToDate(timestamp, timeUnit = 1) {
8625
8625
  return new Date(ms); // JS Date is always internally UTC
8626
8626
  }
8627
8627
 
8628
- function sequence(rows, columns = 1, start = 1, step = 1) {
8628
+ function SEQUENCE(rows, columns = 1, start = 1, step = 1) {
8629
8629
  const result = [];
8630
8630
 
8631
8631
  const isDate = start instanceof Date;
@@ -9233,11 +9233,11 @@ function YEARFRAC(start_date, end_date, basis) {
9233
9233
  }
9234
9234
 
9235
9235
 
9236
- const start = new Date(2025, 0, 1); // Jan 1 2025
9237
- const end = new Date(2025, 11, 31); // Dec 31 2025
9236
+ // const start = new Date(2025, 0, 1); // Jan 1 2025
9237
+ // const end = new Date(2025, 11, 31); // Dec 31 2025
9238
9238
 
9239
- const days = networkDaysIntl(start, end, 7);
9240
- console.log(days);
9239
+ // const days = networkDaysIntl(start, end, 7);
9240
+ // console.log(days);
9241
9241
 
9242
9242
  function isValidBinaryNumber(number) {
9243
9243
  return /^[01]{1,10}$/.test(number)
@@ -30228,6 +30228,7 @@ exports.EDATE = EDATE;
30228
30228
  exports.EFFECT = EFFECT;
30229
30229
  exports.EOA = EOA;
30230
30230
  exports.EOMONTH = EOMONTH;
30231
+ exports.EPOCHTODATE = EPOCHTODATE;
30231
30232
  exports.ERF = ERF;
30232
30233
  exports.ERFC = ERFC;
30233
30234
  exports.ERFCPRECISE = ERFCPRECISE;
@@ -30447,6 +30448,7 @@ exports.SEARCH = SEARCH;
30447
30448
  exports.SEC = SEC;
30448
30449
  exports.SECH = SECH;
30449
30450
  exports.SECOND = SECOND;
30451
+ exports.SEQUENCE = SEQUENCE;
30450
30452
  exports.SERIESSUM = SERIESSUM;
30451
30453
  exports.SIGN = SIGN;
30452
30454
  exports.SIN = SIN;
@@ -30531,9 +30533,4 @@ exports.YEARFRAC = YEARFRAC;
30531
30533
  exports.YIELD = YIELD;
30532
30534
  exports.Z = Z;
30533
30535
  exports.ZTEST = ZTEST;
30534
- exports.epochToDate = epochToDate;
30535
- exports.networkDays = networkDays;
30536
- exports.networkDaysIntl = networkDaysIntl;
30537
- exports.sequence = sequence;
30538
30536
  exports.utils = utils;
30539
- exports.workdayIntl = workdayIntl;