@odoo/o-spreadsheet 17.0.6 → 17.0.8
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/o-spreadsheet.cjs.js +131 -60
- package/dist/o-spreadsheet.d.ts +30 -1
- package/dist/o-spreadsheet.esm.js +131 -60
- package/dist/o-spreadsheet.iife.js +131 -60
- package/dist/o-spreadsheet.iife.min.js +261 -260
- package/dist/o_spreadsheet.xml +3 -3
- package/package.json +2 -2
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* This file is generated by o-spreadsheet build tools. Do not edit it.
|
|
4
4
|
* @see https://github.com/odoo/o-spreadsheet
|
|
5
|
-
* @version 17.0.
|
|
6
|
-
* @date 2024-01-
|
|
7
|
-
* @hash
|
|
5
|
+
* @version 17.0.8
|
|
6
|
+
* @date 2024-01-17T10:27:32.736Z
|
|
7
|
+
* @hash 0f2d46e
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
'use strict';
|
|
@@ -481,7 +481,7 @@ function isBoolean(str) {
|
|
|
481
481
|
const upperCased = str.toUpperCase();
|
|
482
482
|
return upperCased === "TRUE" || upperCased === "FALSE";
|
|
483
483
|
}
|
|
484
|
-
const MARKDOWN_LINK_REGEX = /^\[(
|
|
484
|
+
const MARKDOWN_LINK_REGEX = /^\[(.+)\]\((.+)\)$/;
|
|
485
485
|
//link must start with http or https
|
|
486
486
|
//https://stackoverflow.com/a/3809435/4760614
|
|
487
487
|
const WEB_LINK_REGEX = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;
|
|
@@ -1203,16 +1203,84 @@ function toXC(col, row, rangePart = { colFixed: false, rowFixed: false }) {
|
|
|
1203
1203
|
// -----------------------------------------------------------------------------
|
|
1204
1204
|
// Date Type
|
|
1205
1205
|
// -----------------------------------------------------------------------------
|
|
1206
|
+
/**
|
|
1207
|
+
* A DateTime object that can be used to manipulate spreadsheet dates.
|
|
1208
|
+
* Conceptually, a spreadsheet date is simply a number with a date format,
|
|
1209
|
+
* and it is timezone-agnostic.
|
|
1210
|
+
* This DateTime object consistently uses UTC time to represent a naive date and time.
|
|
1211
|
+
*/
|
|
1212
|
+
class DateTime {
|
|
1213
|
+
jsDate;
|
|
1214
|
+
constructor(year, month, day, hours = 0, minutes = 0, seconds = 0) {
|
|
1215
|
+
this.jsDate = new Date(Date.UTC(year, month, day, hours, minutes, seconds, 0));
|
|
1216
|
+
}
|
|
1217
|
+
static fromTimestamp(timestamp) {
|
|
1218
|
+
const date = new Date(timestamp);
|
|
1219
|
+
return new DateTime(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
|
|
1220
|
+
}
|
|
1221
|
+
static now() {
|
|
1222
|
+
const now = new Date();
|
|
1223
|
+
return new DateTime(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes(), now.getSeconds());
|
|
1224
|
+
}
|
|
1225
|
+
toString() {
|
|
1226
|
+
return this.jsDate.toString();
|
|
1227
|
+
}
|
|
1228
|
+
toLocaleDateString() {
|
|
1229
|
+
return this.jsDate.toLocaleDateString();
|
|
1230
|
+
}
|
|
1231
|
+
getTime() {
|
|
1232
|
+
return this.jsDate.getTime();
|
|
1233
|
+
}
|
|
1234
|
+
getFullYear() {
|
|
1235
|
+
return this.jsDate.getUTCFullYear();
|
|
1236
|
+
}
|
|
1237
|
+
getMonth() {
|
|
1238
|
+
return this.jsDate.getUTCMonth();
|
|
1239
|
+
}
|
|
1240
|
+
getDate() {
|
|
1241
|
+
return this.jsDate.getUTCDate();
|
|
1242
|
+
}
|
|
1243
|
+
getDay() {
|
|
1244
|
+
return this.jsDate.getUTCDay();
|
|
1245
|
+
}
|
|
1246
|
+
getHours() {
|
|
1247
|
+
return this.jsDate.getUTCHours();
|
|
1248
|
+
}
|
|
1249
|
+
getMinutes() {
|
|
1250
|
+
return this.jsDate.getUTCMinutes();
|
|
1251
|
+
}
|
|
1252
|
+
getSeconds() {
|
|
1253
|
+
return this.jsDate.getUTCSeconds();
|
|
1254
|
+
}
|
|
1255
|
+
setFullYear(year) {
|
|
1256
|
+
return this.jsDate.setUTCFullYear(year);
|
|
1257
|
+
}
|
|
1258
|
+
setMonth(month) {
|
|
1259
|
+
return this.jsDate.setUTCMonth(month);
|
|
1260
|
+
}
|
|
1261
|
+
setDate(date) {
|
|
1262
|
+
return this.jsDate.setUTCDate(date);
|
|
1263
|
+
}
|
|
1264
|
+
setHours(hours) {
|
|
1265
|
+
return this.jsDate.setUTCHours(hours);
|
|
1266
|
+
}
|
|
1267
|
+
setMinutes(minutes) {
|
|
1268
|
+
return this.jsDate.setUTCMinutes(minutes);
|
|
1269
|
+
}
|
|
1270
|
+
setSeconds(seconds) {
|
|
1271
|
+
return this.jsDate.setUTCSeconds(seconds);
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1206
1274
|
// -----------------------------------------------------------------------------
|
|
1207
1275
|
// Parsing
|
|
1208
1276
|
// -----------------------------------------------------------------------------
|
|
1209
|
-
const INITIAL_1900_DAY = new
|
|
1277
|
+
const INITIAL_1900_DAY = new DateTime(1899, 11, 30);
|
|
1210
1278
|
const MS_PER_DAY = 24 * 60 * 60 * 1000;
|
|
1211
1279
|
const CURRENT_MILLENIAL = 2000; // note: don't forget to update this in 2999
|
|
1212
|
-
const CURRENT_YEAR =
|
|
1213
|
-
const CURRENT_MONTH =
|
|
1214
|
-
const INITIAL_JS_DAY =
|
|
1215
|
-
const DATE_JS_1900_OFFSET = INITIAL_JS_DAY - INITIAL_1900_DAY;
|
|
1280
|
+
const CURRENT_YEAR = DateTime.now().getFullYear();
|
|
1281
|
+
const CURRENT_MONTH = DateTime.now().getMonth();
|
|
1282
|
+
const INITIAL_JS_DAY = DateTime.fromTimestamp(0);
|
|
1283
|
+
const DATE_JS_1900_OFFSET = INITIAL_JS_DAY.getTime() - INITIAL_1900_DAY.getTime();
|
|
1216
1284
|
const mdyDateRegexp = /^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/;
|
|
1217
1285
|
const ymdDateRegexp = /^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/;
|
|
1218
1286
|
const dateSeparatorsRegex = /\/|-|\s/;
|
|
@@ -1273,7 +1341,7 @@ function _parseDateTime(str, locale) {
|
|
|
1273
1341
|
return {
|
|
1274
1342
|
value: date.value + time.value,
|
|
1275
1343
|
format: date.format + " " + (time.format === "hhhh:mm:ss" ? "hh:mm:ss" : time.format),
|
|
1276
|
-
jsDate: new
|
|
1344
|
+
jsDate: new DateTime(date.jsDate.getFullYear() + time.jsDate.getFullYear() - 1899, date.jsDate.getMonth() + time.jsDate.getMonth() - 11, date.jsDate.getDate() + time.jsDate.getDate() - 30, date.jsDate.getHours() + time.jsDate.getHours(), date.jsDate.getMinutes() + time.jsDate.getMinutes(), date.jsDate.getSeconds() + time.jsDate.getSeconds()),
|
|
1277
1345
|
};
|
|
1278
1346
|
}
|
|
1279
1347
|
return date || time;
|
|
@@ -1349,12 +1417,12 @@ function parseDate(parts, separator) {
|
|
|
1349
1417
|
// month + 1: months are 0-indexed in JS
|
|
1350
1418
|
const leadingZero = (monthStr?.length === 2 && month + 1 < 10) || (dayStr?.length === 2 && day < 10);
|
|
1351
1419
|
const fullYear = yearStr?.length !== 2;
|
|
1352
|
-
const jsDate = new
|
|
1420
|
+
const jsDate = new DateTime(year, month, day);
|
|
1353
1421
|
if (jsDate.getMonth() !== month || jsDate.getDate() !== day) {
|
|
1354
1422
|
// invalid date
|
|
1355
1423
|
return null;
|
|
1356
1424
|
}
|
|
1357
|
-
const delta = jsDate - INITIAL_1900_DAY;
|
|
1425
|
+
const delta = jsDate.getTime() - INITIAL_1900_DAY.getTime();
|
|
1358
1426
|
const format = getFormatFromDateParts(parts, separator, leadingZero, fullYear);
|
|
1359
1427
|
return {
|
|
1360
1428
|
value: Math.round(delta / MS_PER_DAY),
|
|
@@ -1445,7 +1513,7 @@ function parseTime(str) {
|
|
|
1445
1513
|
if (hours >= 24) {
|
|
1446
1514
|
format = "hhhh:mm:ss";
|
|
1447
1515
|
}
|
|
1448
|
-
const jsDate = new
|
|
1516
|
+
const jsDate = new DateTime(1899, 11, 30, hours, minutes, seconds);
|
|
1449
1517
|
return {
|
|
1450
1518
|
value: hours / 24 + minutes / 1440 + seconds / 86400,
|
|
1451
1519
|
format: format,
|
|
@@ -1459,7 +1527,7 @@ function parseTime(str) {
|
|
|
1459
1527
|
// -----------------------------------------------------------------------------
|
|
1460
1528
|
function numberToJsDate(value) {
|
|
1461
1529
|
const truncValue = Math.trunc(value);
|
|
1462
|
-
let date =
|
|
1530
|
+
let date = DateTime.fromTimestamp(truncValue * MS_PER_DAY - DATE_JS_1900_OFFSET);
|
|
1463
1531
|
let time = value - truncValue;
|
|
1464
1532
|
time = time < 0 ? 1 + time : time;
|
|
1465
1533
|
const hours = Math.round(time * 24);
|
|
@@ -1479,7 +1547,7 @@ function jsDateToNumber(date) {
|
|
|
1479
1547
|
}
|
|
1480
1548
|
/** Return the number of days in the current month of the given date */
|
|
1481
1549
|
function getDaysInMonth(date) {
|
|
1482
|
-
return new
|
|
1550
|
+
return new DateTime(date.getFullYear(), date.getMonth() + 1, 0).getDate();
|
|
1483
1551
|
}
|
|
1484
1552
|
function isLastDayOfMonth(date) {
|
|
1485
1553
|
return getDaysInMonth(date) === date.getDate();
|
|
@@ -1497,7 +1565,7 @@ function addMonthsToDate(date, months, keepEndOfMonth) {
|
|
|
1497
1565
|
const yStart = date.getFullYear();
|
|
1498
1566
|
const mStart = date.getMonth();
|
|
1499
1567
|
const dStart = date.getDate();
|
|
1500
|
-
const jsDate = new
|
|
1568
|
+
const jsDate = new DateTime(yStart, mStart + months, 1);
|
|
1501
1569
|
if (keepEndOfMonth && dStart === getDaysInMonth(date)) {
|
|
1502
1570
|
jsDate.setDate(getDaysInMonth(jsDate));
|
|
1503
1571
|
}
|
|
@@ -2720,20 +2788,20 @@ function flattenRowFirst(items, callback) {
|
|
|
2720
2788
|
}
|
|
2721
2789
|
|
|
2722
2790
|
function toCriterionDateNumber(dateValue) {
|
|
2723
|
-
const today =
|
|
2791
|
+
const today = DateTime.now();
|
|
2724
2792
|
switch (dateValue) {
|
|
2725
2793
|
case "today":
|
|
2726
2794
|
return jsDateToNumber(today);
|
|
2727
2795
|
case "yesterday":
|
|
2728
|
-
return jsDateToNumber(
|
|
2796
|
+
return jsDateToNumber(DateTime.fromTimestamp(today.setDate(today.getDate() - 1)));
|
|
2729
2797
|
case "tomorrow":
|
|
2730
|
-
return jsDateToNumber(
|
|
2798
|
+
return jsDateToNumber(DateTime.fromTimestamp(today.setDate(today.getDate() + 1)));
|
|
2731
2799
|
case "lastWeek":
|
|
2732
|
-
return jsDateToNumber(
|
|
2800
|
+
return jsDateToNumber(DateTime.fromTimestamp(today.setDate(today.getDate() - 7)));
|
|
2733
2801
|
case "lastMonth":
|
|
2734
|
-
return jsDateToNumber(
|
|
2802
|
+
return jsDateToNumber(DateTime.fromTimestamp(today.setMonth(today.getMonth() - 1)));
|
|
2735
2803
|
case "lastYear":
|
|
2736
|
-
return jsDateToNumber(
|
|
2804
|
+
return jsDateToNumber(DateTime.fromTimestamp(today.setFullYear(today.getFullYear() - 1)));
|
|
2737
2805
|
}
|
|
2738
2806
|
}
|
|
2739
2807
|
/** Get all the dates values of a criterion converted to numbers, converting date values such as "today" to actual dates */
|
|
@@ -3091,7 +3159,7 @@ function formatJSTime(jsDate, format) {
|
|
|
3091
3159
|
.map((p) => {
|
|
3092
3160
|
switch (p) {
|
|
3093
3161
|
case "hhhh":
|
|
3094
|
-
const helapsedHours = Math.floor((jsDate.getTime() - INITIAL_1900_DAY) / (60 * 60 * 1000));
|
|
3162
|
+
const helapsedHours = Math.floor((jsDate.getTime() - INITIAL_1900_DAY.getTime()) / (60 * 60 * 1000));
|
|
3095
3163
|
return helapsedHours.toString();
|
|
3096
3164
|
case "hh":
|
|
3097
3165
|
return hours.toString().padStart(2, "0");
|
|
@@ -10911,6 +10979,9 @@ function arg(definition, description = "") {
|
|
|
10911
10979
|
function makeArg(str, description) {
|
|
10912
10980
|
let parts = str.match(ARG_REGEXP);
|
|
10913
10981
|
let name = parts[1].trim();
|
|
10982
|
+
if (!name) {
|
|
10983
|
+
throw new Error(`Function argument definition is missing a name: '${str}'.`);
|
|
10984
|
+
}
|
|
10914
10985
|
let types = [];
|
|
10915
10986
|
let isOptional = false;
|
|
10916
10987
|
let isRepeating = false;
|
|
@@ -14616,7 +14687,7 @@ const DATE = {
|
|
|
14616
14687
|
if (_year < 1900) {
|
|
14617
14688
|
_year += 1900;
|
|
14618
14689
|
}
|
|
14619
|
-
const jsDate = new
|
|
14690
|
+
const jsDate = new DateTime(_year, _month - 1, _day);
|
|
14620
14691
|
const result = jsDateToRoundNumber(jsDate);
|
|
14621
14692
|
assert(() => result >= 0, _t("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900."));
|
|
14622
14693
|
return result;
|
|
@@ -14659,7 +14730,7 @@ const DATEDIF = {
|
|
|
14659
14730
|
// See: https://support.microsoft.com/en-us/office/datedif-function-25dba1a4-2812-480b-84dd-8b32a451b35c
|
|
14660
14731
|
let days = jsEndDate.getDate() - jsStartDate.getDate();
|
|
14661
14732
|
if (days < 0) {
|
|
14662
|
-
const monthBeforeEndMonth = new
|
|
14733
|
+
const monthBeforeEndMonth = new DateTime(jsEndDate.getFullYear(), jsEndDate.getMonth() - 1, 1);
|
|
14663
14734
|
const daysInMonthBeforeEndMonth = getDaysInMonth(monthBeforeEndMonth);
|
|
14664
14735
|
days = daysInMonthBeforeEndMonth - Math.abs(days);
|
|
14665
14736
|
}
|
|
@@ -14668,7 +14739,7 @@ const DATEDIF = {
|
|
|
14668
14739
|
if (areTwoDatesWithinOneYear(_startDate, _endDate)) {
|
|
14669
14740
|
return getTimeDifferenceInWholeDays(jsStartDate, jsEndDate);
|
|
14670
14741
|
}
|
|
14671
|
-
const endDateWithinOneYear = new
|
|
14742
|
+
const endDateWithinOneYear = new DateTime(jsStartDate.getFullYear(), jsEndDate.getMonth(), jsEndDate.getDate());
|
|
14672
14743
|
let days = getTimeDifferenceInWholeDays(jsStartDate, endDateWithinOneYear);
|
|
14673
14744
|
if (days < 0) {
|
|
14674
14745
|
endDateWithinOneYear.setFullYear(jsStartDate.getFullYear() + 1);
|
|
@@ -14785,7 +14856,7 @@ const EOMONTH = {
|
|
|
14785
14856
|
const _months = Math.trunc(toNumber(months, this.locale));
|
|
14786
14857
|
const yStart = _startDate.getFullYear();
|
|
14787
14858
|
const mStart = _startDate.getMonth();
|
|
14788
|
-
const jsDate = new
|
|
14859
|
+
const jsDate = new DateTime(yStart, mStart + _months + 1, 0);
|
|
14789
14860
|
return jsDateToRoundNumber(jsDate);
|
|
14790
14861
|
},
|
|
14791
14862
|
isExported: true,
|
|
@@ -14822,17 +14893,17 @@ const ISOWEEKNUM = {
|
|
|
14822
14893
|
// The first week of the year is the week that contains the first
|
|
14823
14894
|
// Thursday of the year.
|
|
14824
14895
|
let firstThursday = 1;
|
|
14825
|
-
while (new
|
|
14896
|
+
while (new DateTime(y, 0, firstThursday).getDay() !== 4) {
|
|
14826
14897
|
firstThursday += 1;
|
|
14827
14898
|
}
|
|
14828
|
-
const firstDayOfFirstWeek = new
|
|
14899
|
+
const firstDayOfFirstWeek = new DateTime(y, 0, firstThursday - 3);
|
|
14829
14900
|
// The last week of the year is the week that contains the last Thursday of
|
|
14830
14901
|
// the year.
|
|
14831
14902
|
let lastThursday = 31;
|
|
14832
|
-
while (new
|
|
14903
|
+
while (new DateTime(y, 11, lastThursday).getDay() !== 4) {
|
|
14833
14904
|
lastThursday -= 1;
|
|
14834
14905
|
}
|
|
14835
|
-
const lastDayOfLastWeek = new
|
|
14906
|
+
const lastDayOfLastWeek = new DateTime(y, 11, lastThursday + 3);
|
|
14836
14907
|
// B - If our date > lastDayOfLastWeek then it's in the weeks of the year after
|
|
14837
14908
|
// If our date < firstDayOfFirstWeek then it's in the weeks of the year before
|
|
14838
14909
|
let offsetYear;
|
|
@@ -14858,17 +14929,17 @@ const ISOWEEKNUM = {
|
|
|
14858
14929
|
case 1:
|
|
14859
14930
|
// firstDay is the 1st day of the 1st week of the year after
|
|
14860
14931
|
// firstDay = lastDayOfLastWeek + 1 Day
|
|
14861
|
-
firstDay = new
|
|
14932
|
+
firstDay = new DateTime(y, 11, lastThursday + 3 + 1);
|
|
14862
14933
|
break;
|
|
14863
14934
|
case -1:
|
|
14864
14935
|
// firstDay is the 1st day of the 1st week of the previous year.
|
|
14865
14936
|
// The first week of the previous year is the week that contains the
|
|
14866
14937
|
// first Thursday of the previous year.
|
|
14867
14938
|
let firstThursdayPreviousYear = 1;
|
|
14868
|
-
while (new
|
|
14939
|
+
while (new DateTime(y - 1, 0, firstThursdayPreviousYear).getDay() !== 4) {
|
|
14869
14940
|
firstThursdayPreviousYear += 1;
|
|
14870
14941
|
}
|
|
14871
|
-
firstDay = new
|
|
14942
|
+
firstDay = new DateTime(y - 1, 0, firstThursdayPreviousYear - 3);
|
|
14872
14943
|
break;
|
|
14873
14944
|
}
|
|
14874
14945
|
const diff = (_date.getTime() - firstDay.getTime()) / MS_PER_DAY;
|
|
@@ -15003,8 +15074,8 @@ const NETWORKDAYS_INTL = {
|
|
|
15003
15074
|
});
|
|
15004
15075
|
}
|
|
15005
15076
|
const invertDate = _startDate.getTime() > _endDate.getTime();
|
|
15006
|
-
const stopDate =
|
|
15007
|
-
let stepDate =
|
|
15077
|
+
const stopDate = DateTime.fromTimestamp((invertDate ? _startDate : _endDate).getTime());
|
|
15078
|
+
let stepDate = DateTime.fromTimestamp((invertDate ? _endDate : _startDate).getTime());
|
|
15008
15079
|
const timeStopDate = stopDate.getTime();
|
|
15009
15080
|
let timeStepDate = stepDate.getTime();
|
|
15010
15081
|
let netWorkingDay = 0;
|
|
@@ -15030,8 +15101,7 @@ const NOW = {
|
|
|
15030
15101
|
return getDateTimeFormat(this.locale);
|
|
15031
15102
|
},
|
|
15032
15103
|
compute: function () {
|
|
15033
|
-
let today =
|
|
15034
|
-
today.setMilliseconds(0);
|
|
15104
|
+
let today = DateTime.now();
|
|
15035
15105
|
const delta = today.getTime() - INITIAL_1900_DAY.getTime();
|
|
15036
15106
|
const time = today.getHours() / 24 + today.getMinutes() / 1440 + today.getSeconds() / 86400;
|
|
15037
15107
|
return Math.floor(delta / MS_PER_DAY) + time;
|
|
@@ -15105,8 +15175,8 @@ const TODAY = {
|
|
|
15105
15175
|
return this.locale.dateFormat;
|
|
15106
15176
|
},
|
|
15107
15177
|
compute: function () {
|
|
15108
|
-
const today =
|
|
15109
|
-
const jsDate = new
|
|
15178
|
+
const today = DateTime.now();
|
|
15179
|
+
const jsDate = new DateTime(today.getFullYear(), today.getMonth(), today.getDate());
|
|
15110
15180
|
return jsDateToRoundNumber(jsDate);
|
|
15111
15181
|
},
|
|
15112
15182
|
isExported: true,
|
|
@@ -15161,10 +15231,10 @@ const WEEKNUM = {
|
|
|
15161
15231
|
}
|
|
15162
15232
|
const y = _date.getFullYear();
|
|
15163
15233
|
let dayStart = 1;
|
|
15164
|
-
let startDayOfFirstWeek = new
|
|
15234
|
+
let startDayOfFirstWeek = new DateTime(y, 0, dayStart);
|
|
15165
15235
|
while (startDayOfFirstWeek.getDay() !== startDayOfWeek) {
|
|
15166
15236
|
dayStart += 1;
|
|
15167
|
-
startDayOfFirstWeek = new
|
|
15237
|
+
startDayOfFirstWeek = new DateTime(y, 0, dayStart);
|
|
15168
15238
|
}
|
|
15169
15239
|
const dif = (_date.getTime() - startDayOfFirstWeek.getTime()) / MS_PER_DAY;
|
|
15170
15240
|
if (dif < 0) {
|
|
@@ -15222,7 +15292,7 @@ const WORKDAY_INTL = {
|
|
|
15222
15292
|
timesHoliday.add(holiday.getTime());
|
|
15223
15293
|
});
|
|
15224
15294
|
}
|
|
15225
|
-
let stepDate =
|
|
15295
|
+
let stepDate = DateTime.fromTimestamp(_startDate.getTime());
|
|
15226
15296
|
let timeStepDate = stepDate.getTime();
|
|
15227
15297
|
const unitDay = Math.sign(_numDays);
|
|
15228
15298
|
let stepDay = Math.abs(_numDays);
|
|
@@ -15286,7 +15356,7 @@ const MONTH_START = {
|
|
|
15286
15356
|
const _startDate = toJsDate(date, this.locale);
|
|
15287
15357
|
const yStart = _startDate.getFullYear();
|
|
15288
15358
|
const mStart = _startDate.getMonth();
|
|
15289
|
-
const jsDate = new
|
|
15359
|
+
const jsDate = new DateTime(yStart, mStart, 1);
|
|
15290
15360
|
return jsDateToRoundNumber(jsDate);
|
|
15291
15361
|
},
|
|
15292
15362
|
};
|
|
@@ -15328,7 +15398,7 @@ const QUARTER_START = {
|
|
|
15328
15398
|
compute: function (date) {
|
|
15329
15399
|
const quarter = QUARTER.compute.bind(this)(date);
|
|
15330
15400
|
const year = YEAR.compute.bind(this)(date);
|
|
15331
|
-
const jsDate = new
|
|
15401
|
+
const jsDate = new DateTime(year, (quarter - 1) * 3, 1);
|
|
15332
15402
|
return jsDateToRoundNumber(jsDate);
|
|
15333
15403
|
},
|
|
15334
15404
|
};
|
|
@@ -15345,7 +15415,7 @@ const QUARTER_END = {
|
|
|
15345
15415
|
compute: function (date) {
|
|
15346
15416
|
const quarter = QUARTER.compute.bind(this)(date);
|
|
15347
15417
|
const year = YEAR.compute.bind(this)(date);
|
|
15348
|
-
const jsDate = new
|
|
15418
|
+
const jsDate = new DateTime(year, quarter * 3, 0);
|
|
15349
15419
|
return jsDateToRoundNumber(jsDate);
|
|
15350
15420
|
},
|
|
15351
15421
|
};
|
|
@@ -15361,7 +15431,7 @@ const YEAR_START = {
|
|
|
15361
15431
|
},
|
|
15362
15432
|
compute: function (date) {
|
|
15363
15433
|
const year = YEAR.compute.bind(this)(date);
|
|
15364
|
-
const jsDate = new
|
|
15434
|
+
const jsDate = new DateTime(year, 0, 1);
|
|
15365
15435
|
return jsDateToRoundNumber(jsDate);
|
|
15366
15436
|
},
|
|
15367
15437
|
};
|
|
@@ -15377,7 +15447,7 @@ const YEAR_END = {
|
|
|
15377
15447
|
},
|
|
15378
15448
|
compute: function (date) {
|
|
15379
15449
|
const year = YEAR.compute.bind(this)(date);
|
|
15380
|
-
const jsDate = new
|
|
15450
|
+
const jsDate = new DateTime(year + 1, 0, 0);
|
|
15381
15451
|
return jsDateToRoundNumber(jsDate);
|
|
15382
15452
|
},
|
|
15383
15453
|
};
|
|
@@ -15425,8 +15495,8 @@ const DEFAULT_DELTA_ARG = 0;
|
|
|
15425
15495
|
const DELTA = {
|
|
15426
15496
|
description: _t("Compare two numeric values, returning 1 if they're equal."),
|
|
15427
15497
|
args: [
|
|
15428
|
-
arg(" (number)", _t("The first number to compare.")),
|
|
15429
|
-
arg(` (number, default=${DEFAULT_DELTA_ARG})`, _t("The second number to compare.")),
|
|
15498
|
+
arg("number1 (number)", _t("The first number to compare.")),
|
|
15499
|
+
arg(`number2 (number, default=${DEFAULT_DELTA_ARG})`, _t("The second number to compare.")),
|
|
15430
15500
|
],
|
|
15431
15501
|
returns: ["NUMBER"],
|
|
15432
15502
|
compute: function (number1, number2 = DEFAULT_DELTA_ARG) {
|
|
@@ -15853,7 +15923,7 @@ function assertDeprecationFactorStrictlyPositive(factor) {
|
|
|
15853
15923
|
function assertSettlementLessThanOneYearBeforeMaturity(settlement, maturity, locale) {
|
|
15854
15924
|
const startDate = toJsDate(settlement, locale);
|
|
15855
15925
|
const endDate = toJsDate(maturity, locale);
|
|
15856
|
-
const startDatePlusOneYear =
|
|
15926
|
+
const startDatePlusOneYear = toJsDate(settlement, locale);
|
|
15857
15927
|
startDatePlusOneYear.setFullYear(startDate.getFullYear() + 1);
|
|
15858
15928
|
assert(() => endDate.getTime() <= startDatePlusOneYear.getTime(), _t("The settlement date (%s) must at most one year after the maturity date (%s).", settlement.toString(), maturity.toString()));
|
|
15859
15929
|
}
|
|
@@ -15988,7 +16058,7 @@ const AMORLINC = {
|
|
|
15988
16058
|
arg("salvage (number)", _t("The value of the asset at the end of depreciation.")),
|
|
15989
16059
|
arg("period (number)", _t("The single period within life for which to calculate depreciation.")),
|
|
15990
16060
|
arg("rate (number)", _t("The deprecation rate.")),
|
|
15991
|
-
arg(" (number, optional)", _t("An indicator of what day count method to use.")),
|
|
16061
|
+
arg("day_count_convention (number, optional)", _t("An indicator of what day count method to use.")),
|
|
15992
16062
|
],
|
|
15993
16063
|
returns: ["NUMBER"],
|
|
15994
16064
|
compute: function (cost, purchaseDate, firstPeriodEnd, salvage, period, rate, dayCountConvention = DEFAULT_DAY_COUNT_CONVENTION) {
|
|
@@ -19012,8 +19082,8 @@ const MID = {
|
|
|
19012
19082
|
description: _t("A segment of a string."),
|
|
19013
19083
|
args: [
|
|
19014
19084
|
arg("text (string)", _t("The string to extract a segment from.")),
|
|
19015
|
-
arg(" (number)", _t("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),
|
|
19016
|
-
arg(" (number)", _t("The length of the segment to extract.")),
|
|
19085
|
+
arg("starting_at (number)", _t("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),
|
|
19086
|
+
arg("extract_length (number)", _t("The length of the segment to extract.")),
|
|
19017
19087
|
],
|
|
19018
19088
|
returns: ["STRING"],
|
|
19019
19089
|
compute: function (text, starting_at, extract_length) {
|
|
@@ -24207,7 +24277,7 @@ dataValidationEvaluatorRegistry.add("dateIs", {
|
|
|
24207
24277
|
return false;
|
|
24208
24278
|
}
|
|
24209
24279
|
if (["lastWeek", "lastMonth", "lastYear"].includes(criterion.dateValue)) {
|
|
24210
|
-
const today = jsDateToRoundNumber(
|
|
24280
|
+
const today = jsDateToRoundNumber(DateTime.now());
|
|
24211
24281
|
return isDateBetween(dateValue, today, criterionValue);
|
|
24212
24282
|
}
|
|
24213
24283
|
return areDatesSameDay(dateValue, criterionValue);
|
|
@@ -27254,6 +27324,7 @@ const CHECKBOX_WIDTH = 15;
|
|
|
27254
27324
|
const MARGIN = (GRID_ICON_EDGE_LENGTH - CHECKBOX_WIDTH) / 2;
|
|
27255
27325
|
css /* scss */ `
|
|
27256
27326
|
.o-dv-checkbox {
|
|
27327
|
+
box-sizing: border-box !important;
|
|
27257
27328
|
width: ${CHECKBOX_WIDTH}px;
|
|
27258
27329
|
height: ${CHECKBOX_WIDTH}px;
|
|
27259
27330
|
accent-color: #808080;
|
|
@@ -38333,9 +38404,9 @@ class RangeAdapter {
|
|
|
38333
38404
|
* Get a Xc string that represent a part of a range
|
|
38334
38405
|
*/
|
|
38335
38406
|
getRangePartString(range, part) {
|
|
38336
|
-
const colFixed = range.parts && range.parts[part]
|
|
38407
|
+
const colFixed = range.parts && range.parts[part]?.colFixed ? "$" : "";
|
|
38337
38408
|
const col = part === 0 ? numberToLetters(range.zone.left) : numberToLetters(range.zone.right);
|
|
38338
|
-
const rowFixed = range.parts && range.parts[part]
|
|
38409
|
+
const rowFixed = range.parts && range.parts[part]?.rowFixed ? "$" : "";
|
|
38339
38410
|
const row = part === 0 ? String(range.zone.top + 1) : String(range.zone.bottom + 1);
|
|
38340
38411
|
let str = "";
|
|
38341
38412
|
if (range.isFullCol) {
|
|
@@ -56699,6 +56770,6 @@ exports.setTranslationMethod = setTranslationMethod;
|
|
|
56699
56770
|
exports.tokenize = tokenize;
|
|
56700
56771
|
|
|
56701
56772
|
|
|
56702
|
-
__info__.version = "17.0.
|
|
56703
|
-
__info__.date = "2024-01-
|
|
56704
|
-
__info__.hash = "
|
|
56773
|
+
__info__.version = "17.0.8";
|
|
56774
|
+
__info__.date = "2024-01-17T10:27:32.736Z";
|
|
56775
|
+
__info__.hash = "0f2d46e";
|
package/dist/o-spreadsheet.d.ts
CHANGED
|
@@ -940,6 +940,35 @@ declare function toCartesian(xc: string): Position$1;
|
|
|
940
940
|
*/
|
|
941
941
|
declare function toXC(col: HeaderIndex, row: HeaderIndex, rangePart?: RangePart): string;
|
|
942
942
|
|
|
943
|
+
/**
|
|
944
|
+
* A DateTime object that can be used to manipulate spreadsheet dates.
|
|
945
|
+
* Conceptually, a spreadsheet date is simply a number with a date format,
|
|
946
|
+
* and it is timezone-agnostic.
|
|
947
|
+
* This DateTime object consistently uses UTC time to represent a naive date and time.
|
|
948
|
+
*/
|
|
949
|
+
declare class DateTime {
|
|
950
|
+
private jsDate;
|
|
951
|
+
constructor(year: number, month: number, day: number, hours?: number, minutes?: number, seconds?: number);
|
|
952
|
+
static fromTimestamp(timestamp: number): DateTime;
|
|
953
|
+
static now(): DateTime;
|
|
954
|
+
toString(): string;
|
|
955
|
+
toLocaleDateString(): string;
|
|
956
|
+
getTime(): number;
|
|
957
|
+
getFullYear(): number;
|
|
958
|
+
getMonth(): number;
|
|
959
|
+
getDate(): number;
|
|
960
|
+
getDay(): number;
|
|
961
|
+
getHours(): number;
|
|
962
|
+
getMinutes(): number;
|
|
963
|
+
getSeconds(): number;
|
|
964
|
+
setFullYear(year: number): number;
|
|
965
|
+
setMonth(month: number): number;
|
|
966
|
+
setDate(date: number): number;
|
|
967
|
+
setHours(hours: number): number;
|
|
968
|
+
setMinutes(minutes: number): number;
|
|
969
|
+
setSeconds(seconds: number): number;
|
|
970
|
+
}
|
|
971
|
+
|
|
943
972
|
/**
|
|
944
973
|
* Formats a cell value with its format.
|
|
945
974
|
*/
|
|
@@ -7717,7 +7746,7 @@ declare class ChartPanel extends Component<Props, SpreadsheetChildEnv> {
|
|
|
7717
7746
|
declare function toNumber(value: string | number | boolean | null | undefined, locale: Locale): number;
|
|
7718
7747
|
declare function toString(value: string | number | boolean | null | undefined): string;
|
|
7719
7748
|
declare function toBoolean(value: string | number | boolean | null | undefined): boolean;
|
|
7720
|
-
declare function toJsDate(value: string | number | boolean | null | undefined, locale: Locale):
|
|
7749
|
+
declare function toJsDate(value: string | number | boolean | null | undefined, locale: Locale): DateTime;
|
|
7721
7750
|
|
|
7722
7751
|
declare function arg(definition: string, description?: string): ArgDefinition;
|
|
7723
7752
|
|