@fileverse-dev/formulajs 4.4.34 → 4.4.36
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 +38 -41
- package/lib/browser/formula.min.js +2 -2
- package/lib/browser/formula.min.js.map +1 -1
- package/lib/cjs/index.cjs +36 -204
- package/lib/esm/index.mjs +36 -204
- package/package.json +1 -1
- package/types/cjs/index.d.cts +3 -3
- package/types/esm/index.d.mts +3 -3
package/lib/browser/formula.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @fileverse-dev/formulajs v4.4.
|
|
1
|
+
/* @fileverse-dev/formulajs v4.4.36 */
|
|
2
2
|
var _excluded = [ "confirmations", "dataDecoded" ];
|
|
3
3
|
|
|
4
4
|
function _objectWithoutProperties(e, t) {
|
|
@@ -8358,6 +8358,25 @@ function _typeof(o) {
|
|
|
8358
8358
|
var WEEK_STARTS = [ undefined, 0, 1, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, 1, 2, 3, 4, 5, 6, 0 ];
|
|
8359
8359
|
var WEEK_TYPES = [ [], [ 1, 2, 3, 4, 5, 6, 7 ], [ 7, 1, 2, 3, 4, 5, 6 ], [ 6, 0, 1, 2, 3, 4, 5 ], [], [], [], [], [], [], [], [ 7, 1, 2, 3, 4, 5, 6 ], [ 6, 7, 1, 2, 3, 4, 5 ], [ 5, 6, 7, 1, 2, 3, 4 ], [ 4, 5, 6, 7, 1, 2, 3 ], [ 3, 4, 5, 6, 7, 1, 2 ], [ 2, 3, 4, 5, 6, 7, 1 ], [ 1, 2, 3, 4, 5, 6, 7 ] ];
|
|
8360
8360
|
var WEEKEND_TYPES = [ [], [ 6, 0 ], [ 0, 1 ], [ 1, 2 ], [ 2, 3 ], [ 3, 4 ], [ 4, 5 ], [ 5, 6 ], undefined, undefined, undefined, [ 0, 0 ], [ 1, 1 ], [ 2, 2 ], [ 3, 3 ], [ 4, 4 ], [ 5, 5 ], [ 6, 6 ] ];
|
|
8361
|
+
var datePartition = function datePartition(date) {
|
|
8362
|
+
var pad = function pad(n) {
|
|
8363
|
+
return n.toString().padStart(2, "0");
|
|
8364
|
+
};
|
|
8365
|
+
var day = pad(date.getDate());
|
|
8366
|
+
var month = pad(date.getMonth() + 1);
|
|
8367
|
+
var year = date.getFullYear();
|
|
8368
|
+
var hours = pad(date.getHours());
|
|
8369
|
+
var minutes = pad(date.getMinutes());
|
|
8370
|
+
var seconds = pad(date.getSeconds());
|
|
8371
|
+
return {
|
|
8372
|
+
day: day,
|
|
8373
|
+
month: month,
|
|
8374
|
+
year: year,
|
|
8375
|
+
hours: hours,
|
|
8376
|
+
minutes: minutes,
|
|
8377
|
+
seconds: seconds
|
|
8378
|
+
};
|
|
8379
|
+
};
|
|
8361
8380
|
function DATE(year, month, day) {
|
|
8362
8381
|
var result;
|
|
8363
8382
|
year = parseNumber(year);
|
|
@@ -8370,12 +8389,7 @@ function _typeof(o) {
|
|
|
8370
8389
|
if (result.getFullYear() < 0) {
|
|
8371
8390
|
result = num;
|
|
8372
8391
|
}
|
|
8373
|
-
var
|
|
8374
|
-
return n.toString().padStart(2, "0");
|
|
8375
|
-
};
|
|
8376
|
-
var dayResult = pad(result.getDate());
|
|
8377
|
-
var monthResult = pad(result.getMonth() + 1);
|
|
8378
|
-
var yearResult = result.getFullYear();
|
|
8392
|
+
var _datePartition = datePartition(result), dayResult = _datePartition.day, monthResult = _datePartition.month, yearResult = _datePartition.year;
|
|
8379
8393
|
result = "".concat(dayResult, "/").concat(monthResult, "/").concat(yearResult);
|
|
8380
8394
|
}
|
|
8381
8395
|
return returnSerial ? dateToSerial(result) : result;
|
|
@@ -8450,7 +8464,7 @@ function _typeof(o) {
|
|
|
8450
8464
|
return value;
|
|
8451
8465
|
}
|
|
8452
8466
|
var dateValue = new Date(date_text);
|
|
8453
|
-
return
|
|
8467
|
+
return dateToSerial(dateValue);
|
|
8454
8468
|
}
|
|
8455
8469
|
function DAY(serial_number) {
|
|
8456
8470
|
var date = parseDate(serial_number);
|
|
@@ -8535,12 +8549,7 @@ function _typeof(o) {
|
|
|
8535
8549
|
}
|
|
8536
8550
|
start_date.setDate(storedDay);
|
|
8537
8551
|
var widthoutSerial = start_date;
|
|
8538
|
-
var
|
|
8539
|
-
return n.toString().padStart(2, "0");
|
|
8540
|
-
};
|
|
8541
|
-
var dayResult = pad(widthoutSerial.getDate());
|
|
8542
|
-
var monthResult = pad(widthoutSerial.getMonth() + 1);
|
|
8543
|
-
var yearResult = widthoutSerial.getFullYear();
|
|
8552
|
+
var _datePartition2 = datePartition(widthoutSerial), dayResult = _datePartition2.day, monthResult = _datePartition2.month, yearResult = _datePartition2.year;
|
|
8544
8553
|
widthoutSerial = "".concat(dayResult, "/").concat(monthResult, "/").concat(yearResult);
|
|
8545
8554
|
return returnSerial ? dateToSerial(start_date) : widthoutSerial;
|
|
8546
8555
|
}
|
|
@@ -8555,17 +8564,15 @@ function _typeof(o) {
|
|
|
8555
8564
|
months = parseInt(months, 10);
|
|
8556
8565
|
var eoMonth = new Date(start_date.getFullYear(), start_date.getMonth() + months + 1, 0);
|
|
8557
8566
|
var widthoutSerial = eoMonth;
|
|
8558
|
-
var
|
|
8559
|
-
return n.toString().padStart(2, "0");
|
|
8560
|
-
};
|
|
8561
|
-
var dayResult = pad(widthoutSerial.getDate());
|
|
8562
|
-
var monthResult = pad(widthoutSerial.getMonth() + 1);
|
|
8563
|
-
var yearResult = widthoutSerial.getFullYear();
|
|
8567
|
+
var _datePartition3 = datePartition(widthoutSerial), dayResult = _datePartition3.day, monthResult = _datePartition3.month, yearResult = _datePartition3.year;
|
|
8564
8568
|
widthoutSerial = "".concat(dayResult, "/").concat(monthResult, "/").concat(yearResult);
|
|
8565
8569
|
return returnSerial ? dateToSerial(eoMonth) : widthoutSerial;
|
|
8566
8570
|
}
|
|
8567
8571
|
function EPOCHTODATE(timestamp) {
|
|
8568
8572
|
var timeUnit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
8573
|
+
if (isNaN(timestamp)) {
|
|
8574
|
+
return num;
|
|
8575
|
+
}
|
|
8569
8576
|
var ms;
|
|
8570
8577
|
switch (timeUnit) {
|
|
8571
8578
|
case 1:
|
|
@@ -8583,29 +8590,27 @@ function _typeof(o) {
|
|
|
8583
8590
|
default:
|
|
8584
8591
|
throw new Error("Invalid time_unit. Use 1 (sec), 2 (ms), or 3 (µs).");
|
|
8585
8592
|
}
|
|
8586
|
-
|
|
8593
|
+
var d = new Date(ms);
|
|
8594
|
+
var _datePartition4 = datePartition(d), day = _datePartition4.day, month = _datePartition4.month, year = _datePartition4.year, hours = _datePartition4.hours, minutes = _datePartition4.minutes, seconds = _datePartition4.seconds;
|
|
8595
|
+
return "".concat(day, "/").concat(month, "/").concat(year, " ").concat(hours, ":").concat(minutes, ":").concat(seconds);
|
|
8587
8596
|
}
|
|
8588
8597
|
function SEQUENCE(rows) {
|
|
8589
8598
|
var columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
8590
8599
|
var start = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
8591
8600
|
var step = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
8592
8601
|
var result = [];
|
|
8593
|
-
var
|
|
8594
|
-
|
|
8595
|
-
|
|
8602
|
+
var isDateInput = function isDateInput(val) {
|
|
8603
|
+
if (val instanceof Date) return true;
|
|
8604
|
+
if (typeof val === "string" && !isNaN(Date.parse(val))) return true;
|
|
8605
|
+
return false;
|
|
8596
8606
|
};
|
|
8597
|
-
|
|
8607
|
+
var isDate = isDateInput(start);
|
|
8608
|
+
if (isDate) start = DATEVALUE(start);
|
|
8598
8609
|
for (var r = 0; r < rows; r++) {
|
|
8599
8610
|
var row = [];
|
|
8600
8611
|
for (var c = 0; c < columns; c++) {
|
|
8601
8612
|
var index = r * columns + c;
|
|
8602
|
-
|
|
8603
|
-
var d = new Date(start);
|
|
8604
|
-
d.setDate(start.getDate() + index * step);
|
|
8605
|
-
row.push(d);
|
|
8606
|
-
} else {
|
|
8607
|
-
row.push(start + index * step);
|
|
8608
|
-
}
|
|
8613
|
+
row.push(start + index * step);
|
|
8609
8614
|
}
|
|
8610
8615
|
result.push(row);
|
|
8611
8616
|
}
|
|
@@ -8709,15 +8714,7 @@ function _typeof(o) {
|
|
|
8709
8714
|
var NETWORKDAYS_INTL = NETWORKDAYS.INTL;
|
|
8710
8715
|
function NOW() {
|
|
8711
8716
|
var d = new Date;
|
|
8712
|
-
var
|
|
8713
|
-
return n.toString().padStart(2, "0");
|
|
8714
|
-
};
|
|
8715
|
-
var day = pad(d.getDate());
|
|
8716
|
-
var month = pad(d.getMonth() + 1);
|
|
8717
|
-
var year = d.getFullYear();
|
|
8718
|
-
var hours = pad(d.getHours());
|
|
8719
|
-
var minutes = pad(d.getMinutes());
|
|
8720
|
-
var seconds = pad(d.getSeconds());
|
|
8717
|
+
var _datePartition5 = datePartition(d), day = _datePartition5.day, month = _datePartition5.month, year = _datePartition5.year, hours = _datePartition5.hours, minutes = _datePartition5.minutes, seconds = _datePartition5.seconds;
|
|
8721
8718
|
return returnSerial ? dateToSerial(d) : "".concat(day, "/").concat(month, "/").concat(year, " ").concat(hours, ":").concat(minutes, ":").concat(seconds);
|
|
8722
8719
|
}
|
|
8723
8720
|
function SECOND(serial_number) {
|