@odoo/o-spreadsheet 16.0.27 → 16.0.29
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 +144 -44
- package/dist/o-spreadsheet.d.ts +28 -1
- package/dist/o-spreadsheet.esm.js +144 -44
- package/dist/o-spreadsheet.iife.js +144 -44
- package/dist/o-spreadsheet.iife.min.js +246 -246
- package/dist/o_spreadsheet.xml +3 -3
- package/package.json +1 -1
|
@@ -307,15 +307,76 @@ for (let font of fontSizes) {
|
|
|
307
307
|
// -----------------------------------------------------------------------------
|
|
308
308
|
// Date Type
|
|
309
309
|
// -----------------------------------------------------------------------------
|
|
310
|
+
/**
|
|
311
|
+
* A DateTime object that can be used to manipulate spreadsheet dates.
|
|
312
|
+
* Conceptually, a spreadsheet date is simply a number with a date format,
|
|
313
|
+
* and it is timezone-agnostic.
|
|
314
|
+
* This DateTime object consistently uses UTC time to represent a naive date and time.
|
|
315
|
+
*/
|
|
316
|
+
class DateTime {
|
|
317
|
+
constructor(year, month, day, hours = 0, minutes = 0, seconds = 0) {
|
|
318
|
+
this.jsDate = new Date(Date.UTC(year, month, day, hours, minutes, seconds, 0));
|
|
319
|
+
}
|
|
320
|
+
static fromTimestamp(timestamp) {
|
|
321
|
+
const date = new Date(timestamp);
|
|
322
|
+
return new DateTime(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
|
|
323
|
+
}
|
|
324
|
+
static now() {
|
|
325
|
+
const now = new Date();
|
|
326
|
+
return new DateTime(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes(), now.getSeconds());
|
|
327
|
+
}
|
|
328
|
+
toString() {
|
|
329
|
+
return this.jsDate.toString();
|
|
330
|
+
}
|
|
331
|
+
getTime() {
|
|
332
|
+
return this.jsDate.getTime();
|
|
333
|
+
}
|
|
334
|
+
getFullYear() {
|
|
335
|
+
return this.jsDate.getUTCFullYear();
|
|
336
|
+
}
|
|
337
|
+
getMonth() {
|
|
338
|
+
return this.jsDate.getUTCMonth();
|
|
339
|
+
}
|
|
340
|
+
getDate() {
|
|
341
|
+
return this.jsDate.getUTCDate();
|
|
342
|
+
}
|
|
343
|
+
getDay() {
|
|
344
|
+
return this.jsDate.getUTCDay();
|
|
345
|
+
}
|
|
346
|
+
getHours() {
|
|
347
|
+
return this.jsDate.getUTCHours();
|
|
348
|
+
}
|
|
349
|
+
getMinutes() {
|
|
350
|
+
return this.jsDate.getUTCMinutes();
|
|
351
|
+
}
|
|
352
|
+
getSeconds() {
|
|
353
|
+
return this.jsDate.getUTCSeconds();
|
|
354
|
+
}
|
|
355
|
+
setFullYear(year) {
|
|
356
|
+
this.jsDate.setFullYear(year);
|
|
357
|
+
}
|
|
358
|
+
setDate(date) {
|
|
359
|
+
this.jsDate.setUTCDate(date);
|
|
360
|
+
}
|
|
361
|
+
setHours(hours) {
|
|
362
|
+
this.jsDate.setUTCHours(hours);
|
|
363
|
+
}
|
|
364
|
+
setMinutes(minutes) {
|
|
365
|
+
this.jsDate.setUTCMinutes(minutes);
|
|
366
|
+
}
|
|
367
|
+
setSeconds(seconds) {
|
|
368
|
+
this.jsDate.setUTCSeconds(seconds);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
310
371
|
// -----------------------------------------------------------------------------
|
|
311
372
|
// Parsing
|
|
312
373
|
// -----------------------------------------------------------------------------
|
|
313
|
-
const INITIAL_1900_DAY = new
|
|
374
|
+
const INITIAL_1900_DAY = new DateTime(1899, 11, 30);
|
|
314
375
|
const MS_PER_DAY = 24 * 60 * 60 * 1000;
|
|
315
376
|
const CURRENT_MILLENIAL = 2000; // note: don't forget to update this in 2999
|
|
316
|
-
const CURRENT_YEAR =
|
|
317
|
-
const INITIAL_JS_DAY =
|
|
318
|
-
const DATE_JS_1900_OFFSET = INITIAL_JS_DAY - INITIAL_1900_DAY;
|
|
377
|
+
const CURRENT_YEAR = DateTime.now().getFullYear();
|
|
378
|
+
const INITIAL_JS_DAY = DateTime.fromTimestamp(0);
|
|
379
|
+
const DATE_JS_1900_OFFSET = INITIAL_JS_DAY.getTime() - INITIAL_1900_DAY.getTime();
|
|
319
380
|
const mdyDateRegexp = /^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/;
|
|
320
381
|
const ymdDateRegexp = /^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/;
|
|
321
382
|
const timeRegexp = /((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;
|
|
@@ -364,7 +425,7 @@ function _parseDateTime(str) {
|
|
|
364
425
|
return {
|
|
365
426
|
value: date.value + time.value,
|
|
366
427
|
format: date.format + " " + (time.format === "hhhh:mm:ss" ? "hh:mm:ss" : time.format),
|
|
367
|
-
jsDate: new
|
|
428
|
+
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()),
|
|
368
429
|
};
|
|
369
430
|
}
|
|
370
431
|
return date || time;
|
|
@@ -381,13 +442,13 @@ function parseDate(str, dateFormat) {
|
|
|
381
442
|
const day = Number(parts[dayIndex]);
|
|
382
443
|
const leadingZero = (parts[monthIndex].length === 2 && month < 10) || (parts[dayIndex].length === 2 && day < 10);
|
|
383
444
|
const year = parts[yearIndex] ? inferYear(parts[yearIndex]) : CURRENT_YEAR;
|
|
384
|
-
const jsDate = new
|
|
445
|
+
const jsDate = new DateTime(year, month - 1, day);
|
|
385
446
|
const sep = str.match(/\/|-|\s/)[0];
|
|
386
447
|
if (jsDate.getMonth() !== month - 1 || jsDate.getDate() !== day) {
|
|
387
448
|
// invalid date
|
|
388
449
|
return null;
|
|
389
450
|
}
|
|
390
|
-
const delta = jsDate - INITIAL_1900_DAY;
|
|
451
|
+
const delta = jsDate.getTime() - INITIAL_1900_DAY.getTime();
|
|
391
452
|
let format = leadingZero ? `mm${sep}dd` : `m${sep}d`;
|
|
392
453
|
if (parts[yearIndex]) {
|
|
393
454
|
format = isMDY ? format + sep + "yyyy" : "yyyy" + sep + format;
|
|
@@ -447,7 +508,7 @@ function parseTime(str) {
|
|
|
447
508
|
if (hours >= 24) {
|
|
448
509
|
format = "hhhh:mm:ss";
|
|
449
510
|
}
|
|
450
|
-
const jsDate = new
|
|
511
|
+
const jsDate = new DateTime(1899, 11, 30, hours, minutes, seconds);
|
|
451
512
|
return {
|
|
452
513
|
value: hours / 24 + minutes / 1440 + seconds / 86400,
|
|
453
514
|
format: format,
|
|
@@ -461,7 +522,7 @@ function parseTime(str) {
|
|
|
461
522
|
// -----------------------------------------------------------------------------
|
|
462
523
|
function numberToJsDate(value) {
|
|
463
524
|
const truncValue = Math.trunc(value);
|
|
464
|
-
let date =
|
|
525
|
+
let date = DateTime.fromTimestamp(truncValue * MS_PER_DAY - DATE_JS_1900_OFFSET);
|
|
465
526
|
let time = value - truncValue;
|
|
466
527
|
time = time < 0 ? 1 + time : time;
|
|
467
528
|
const hours = Math.round(time * 24);
|
|
@@ -478,7 +539,7 @@ function jsDateToRoundNumber(date) {
|
|
|
478
539
|
}
|
|
479
540
|
/** Return the number of days in the current month of the given date */
|
|
480
541
|
function getDaysInMonth(date) {
|
|
481
|
-
return new
|
|
542
|
+
return new DateTime(date.getFullYear(), date.getMonth() + 1, 0).getDate();
|
|
482
543
|
}
|
|
483
544
|
function isLastDayOfMonth(date) {
|
|
484
545
|
return getDaysInMonth(date) === date.getDate();
|
|
@@ -496,7 +557,7 @@ function addMonthsToDate(date, months, keepEndOfMonth) {
|
|
|
496
557
|
const yStart = date.getFullYear();
|
|
497
558
|
const mStart = date.getMonth();
|
|
498
559
|
const dStart = date.getDate();
|
|
499
|
-
const jsDate = new
|
|
560
|
+
const jsDate = new DateTime(yStart, mStart + months, 1);
|
|
500
561
|
if (keepEndOfMonth && dStart === getDaysInMonth(date)) {
|
|
501
562
|
jsDate.setDate(getDaysInMonth(jsDate));
|
|
502
563
|
}
|
|
@@ -849,7 +910,7 @@ function isBoolean(str) {
|
|
|
849
910
|
function isDateTime(str) {
|
|
850
911
|
return parseDateTime(str) !== null;
|
|
851
912
|
}
|
|
852
|
-
const MARKDOWN_LINK_REGEX = /^\[(
|
|
913
|
+
const MARKDOWN_LINK_REGEX = /^\[(.+)\]\((.+)\)$/;
|
|
853
914
|
//link must start with http or https
|
|
854
915
|
//https://stackoverflow.com/a/3809435/4760614
|
|
855
916
|
const WEB_LINK_REGEX = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;
|
|
@@ -1504,6 +1565,31 @@ const MAX_DECIMAL_PLACES = 20;
|
|
|
1504
1565
|
//from https://stackoverflow.com/questions/721304/insert-commas-into-number-string @Thomas/Alan Moore
|
|
1505
1566
|
const thousandsGroupsRegexp = /(\d+?)(?=(\d{3})+(?!\d)|$)/g;
|
|
1506
1567
|
const zeroRegexp = /0/g;
|
|
1568
|
+
// TODO in the future : remove these constants MONTHS/DAYS, and use a library such as luxon to handle it
|
|
1569
|
+
// + possibly handle automatic translation of day/month
|
|
1570
|
+
const MONTHS = {
|
|
1571
|
+
0: _lt("January"),
|
|
1572
|
+
1: _lt("February"),
|
|
1573
|
+
2: _lt("March"),
|
|
1574
|
+
3: _lt("April"),
|
|
1575
|
+
4: _lt("May"),
|
|
1576
|
+
5: _lt("June"),
|
|
1577
|
+
6: _lt("July"),
|
|
1578
|
+
7: _lt("August"),
|
|
1579
|
+
8: _lt("September"),
|
|
1580
|
+
9: _lt("October"),
|
|
1581
|
+
10: _lt("November"),
|
|
1582
|
+
11: _lt("December"),
|
|
1583
|
+
};
|
|
1584
|
+
const DAYS$1 = {
|
|
1585
|
+
0: _lt("Sunday"),
|
|
1586
|
+
1: _lt("Monday"),
|
|
1587
|
+
2: _lt("Tuesday"),
|
|
1588
|
+
3: _lt("Wednesday"),
|
|
1589
|
+
4: _lt("Thursday"),
|
|
1590
|
+
5: _lt("Friday"),
|
|
1591
|
+
6: _lt("Saturday"),
|
|
1592
|
+
};
|
|
1507
1593
|
// -----------------------------------------------------------------------------
|
|
1508
1594
|
// FORMAT REPRESENTATION CACHE
|
|
1509
1595
|
// -----------------------------------------------------------------------------
|
|
@@ -1736,8 +1822,9 @@ function applyDateTimeFormat(value, format) {
|
|
|
1736
1822
|
return strDate + (strDate && strTime ? " " : "") + strTime;
|
|
1737
1823
|
}
|
|
1738
1824
|
function formatJSDate(jsDate, format) {
|
|
1739
|
-
|
|
1740
|
-
const
|
|
1825
|
+
var _a;
|
|
1826
|
+
const sep = (_a = format.match(/\/|-|\s/)) === null || _a === void 0 ? void 0 : _a[0];
|
|
1827
|
+
const parts = sep ? format.split(sep) : [format];
|
|
1741
1828
|
return parts
|
|
1742
1829
|
.map((p) => {
|
|
1743
1830
|
switch (p) {
|
|
@@ -1745,10 +1832,23 @@ function formatJSDate(jsDate, format) {
|
|
|
1745
1832
|
return jsDate.getDate();
|
|
1746
1833
|
case "dd":
|
|
1747
1834
|
return jsDate.getDate().toString().padStart(2, "0");
|
|
1835
|
+
case "ddd":
|
|
1836
|
+
return DAYS$1[jsDate.getDay()].slice(0, 3);
|
|
1837
|
+
case "dddd":
|
|
1838
|
+
return DAYS$1[jsDate.getDay()];
|
|
1748
1839
|
case "m":
|
|
1749
1840
|
return jsDate.getMonth() + 1;
|
|
1750
1841
|
case "mm":
|
|
1751
1842
|
return String(jsDate.getMonth() + 1).padStart(2, "0");
|
|
1843
|
+
case "mmm":
|
|
1844
|
+
return MONTHS[jsDate.getMonth()].slice(0, 3);
|
|
1845
|
+
case "mmmm":
|
|
1846
|
+
return MONTHS[jsDate.getMonth()];
|
|
1847
|
+
case "mmmmm":
|
|
1848
|
+
return MONTHS[jsDate.getMonth()].slice(0, 1);
|
|
1849
|
+
case "yy":
|
|
1850
|
+
const fullYear = String(jsDate.getFullYear()).replace("-", "").padStart(2, "0");
|
|
1851
|
+
return fullYear.slice(fullYear.length - 2);
|
|
1752
1852
|
case "yyyy":
|
|
1753
1853
|
return jsDate.getFullYear();
|
|
1754
1854
|
default:
|
|
@@ -1772,7 +1872,7 @@ function formatJSTime(jsDate, format) {
|
|
|
1772
1872
|
.map((p) => {
|
|
1773
1873
|
switch (p) {
|
|
1774
1874
|
case "hhhh":
|
|
1775
|
-
const helapsedHours = Math.floor((jsDate.getTime() - INITIAL_1900_DAY) / (60 * 60 * 1000));
|
|
1875
|
+
const helapsedHours = Math.floor((jsDate.getTime() - INITIAL_1900_DAY.getTime()) / (60 * 60 * 1000));
|
|
1776
1876
|
return helapsedHours.toString();
|
|
1777
1877
|
case "hh":
|
|
1778
1878
|
return hours.toString().padStart(2, "0");
|
|
@@ -13848,7 +13948,7 @@ const DATE = {
|
|
|
13848
13948
|
if (_year < 1900) {
|
|
13849
13949
|
_year += 1900;
|
|
13850
13950
|
}
|
|
13851
|
-
const jsDate = new
|
|
13951
|
+
const jsDate = new DateTime(_year, _month - 1, _day);
|
|
13852
13952
|
const result = jsDateToRoundNumber(jsDate);
|
|
13853
13953
|
assert(() => result >= 0, _lt(`The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.`));
|
|
13854
13954
|
return result;
|
|
@@ -13960,7 +14060,7 @@ const EOMONTH = {
|
|
|
13960
14060
|
const _months = Math.trunc(toNumber(months));
|
|
13961
14061
|
const yStart = _startDate.getFullYear();
|
|
13962
14062
|
const mStart = _startDate.getMonth();
|
|
13963
|
-
const jsDate = new
|
|
14063
|
+
const jsDate = new DateTime(yStart, mStart + _months + 1, 0);
|
|
13964
14064
|
return jsDateToRoundNumber(jsDate);
|
|
13965
14065
|
},
|
|
13966
14066
|
isExported: true,
|
|
@@ -13999,17 +14099,17 @@ const ISOWEEKNUM = {
|
|
|
13999
14099
|
// The first week of the year is the week that contains the first
|
|
14000
14100
|
// Thursday of the year.
|
|
14001
14101
|
let firstThursday = 1;
|
|
14002
|
-
while (new
|
|
14102
|
+
while (new DateTime(y, 0, firstThursday).getDay() !== 4) {
|
|
14003
14103
|
firstThursday += 1;
|
|
14004
14104
|
}
|
|
14005
|
-
const firstDayOfFirstWeek = new
|
|
14105
|
+
const firstDayOfFirstWeek = new DateTime(y, 0, firstThursday - 3);
|
|
14006
14106
|
// The last week of the year is the week that contains the last Thursday of
|
|
14007
14107
|
// the year.
|
|
14008
14108
|
let lastThursday = 31;
|
|
14009
|
-
while (new
|
|
14109
|
+
while (new DateTime(y, 11, lastThursday).getDay() !== 4) {
|
|
14010
14110
|
lastThursday -= 1;
|
|
14011
14111
|
}
|
|
14012
|
-
const lastDayOfLastWeek = new
|
|
14112
|
+
const lastDayOfLastWeek = new DateTime(y, 11, lastThursday + 3);
|
|
14013
14113
|
// B - If our date > lastDayOfLastWeek then it's in the weeks of the year after
|
|
14014
14114
|
// If our date < firstDayOfFirstWeek then it's in the weeks of the year before
|
|
14015
14115
|
let offsetYear;
|
|
@@ -14035,17 +14135,17 @@ const ISOWEEKNUM = {
|
|
|
14035
14135
|
case 1:
|
|
14036
14136
|
// firstDay is the 1st day of the 1st week of the year after
|
|
14037
14137
|
// firstDay = lastDayOfLastWeek + 1 Day
|
|
14038
|
-
firstDay = new
|
|
14138
|
+
firstDay = new DateTime(y, 11, lastThursday + 3 + 1);
|
|
14039
14139
|
break;
|
|
14040
14140
|
case -1:
|
|
14041
14141
|
// firstDay is the 1st day of the 1st week of the previous year.
|
|
14042
14142
|
// The first week of the previous year is the week that contains the
|
|
14043
14143
|
// first Thursday of the previous year.
|
|
14044
14144
|
let firstThursdayPreviousYear = 1;
|
|
14045
|
-
while (new
|
|
14145
|
+
while (new DateTime(y - 1, 0, firstThursdayPreviousYear).getDay() !== 4) {
|
|
14046
14146
|
firstThursdayPreviousYear += 1;
|
|
14047
14147
|
}
|
|
14048
|
-
firstDay = new
|
|
14148
|
+
firstDay = new DateTime(y - 1, 0, firstThursdayPreviousYear - 3);
|
|
14049
14149
|
break;
|
|
14050
14150
|
}
|
|
14051
14151
|
const diff = (_date.getTime() - firstDay.getTime()) / MS_PER_DAY;
|
|
@@ -14184,8 +14284,8 @@ const NETWORKDAYS_INTL = {
|
|
|
14184
14284
|
});
|
|
14185
14285
|
}
|
|
14186
14286
|
const invertDate = _startDate.getTime() > _endDate.getTime();
|
|
14187
|
-
const stopDate =
|
|
14188
|
-
let stepDate =
|
|
14287
|
+
const stopDate = DateTime.fromTimestamp((invertDate ? _startDate : _endDate).getTime());
|
|
14288
|
+
let stepDate = DateTime.fromTimestamp((invertDate ? _endDate : _startDate).getTime());
|
|
14189
14289
|
const timeStopDate = stopDate.getTime();
|
|
14190
14290
|
let timeStepDate = stepDate.getTime();
|
|
14191
14291
|
let netWorkingDay = 0;
|
|
@@ -14209,8 +14309,7 @@ const NOW = {
|
|
|
14209
14309
|
returns: ["DATE"],
|
|
14210
14310
|
computeFormat: () => "m/d/yyyy hh:mm:ss",
|
|
14211
14311
|
compute: function () {
|
|
14212
|
-
let today =
|
|
14213
|
-
today.setMilliseconds(0);
|
|
14312
|
+
let today = DateTime.now();
|
|
14214
14313
|
const delta = today.getTime() - INITIAL_1900_DAY.getTime();
|
|
14215
14314
|
const time = today.getHours() / 24 + today.getMinutes() / 1440 + today.getSeconds() / 86400;
|
|
14216
14315
|
return Math.floor(delta / MS_PER_DAY) + time;
|
|
@@ -14284,8 +14383,8 @@ const TODAY = {
|
|
|
14284
14383
|
returns: ["DATE"],
|
|
14285
14384
|
computeFormat: () => "m/d/yyyy",
|
|
14286
14385
|
compute: function () {
|
|
14287
|
-
const today =
|
|
14288
|
-
const jsDate = new
|
|
14386
|
+
const today = DateTime.now();
|
|
14387
|
+
const jsDate = new DateTime(today.getFullYear(), today.getMonth(), today.getDate());
|
|
14289
14388
|
return jsDateToRoundNumber(jsDate);
|
|
14290
14389
|
},
|
|
14291
14390
|
isExported: true,
|
|
@@ -14340,10 +14439,10 @@ const WEEKNUM = {
|
|
|
14340
14439
|
}
|
|
14341
14440
|
const y = _date.getFullYear();
|
|
14342
14441
|
let dayStart = 1;
|
|
14343
|
-
let startDayOfFirstWeek = new
|
|
14442
|
+
let startDayOfFirstWeek = new DateTime(y, 0, dayStart);
|
|
14344
14443
|
while (startDayOfFirstWeek.getDay() !== startDayOfWeek) {
|
|
14345
14444
|
dayStart += 1;
|
|
14346
|
-
startDayOfFirstWeek = new
|
|
14445
|
+
startDayOfFirstWeek = new DateTime(y, 0, dayStart);
|
|
14347
14446
|
}
|
|
14348
14447
|
const dif = (_date.getTime() - startDayOfFirstWeek.getTime()) / MS_PER_DAY;
|
|
14349
14448
|
if (dif < 0) {
|
|
@@ -14397,7 +14496,7 @@ const WORKDAY_INTL = {
|
|
|
14397
14496
|
timesHoliday.add(holiday.getTime());
|
|
14398
14497
|
});
|
|
14399
14498
|
}
|
|
14400
|
-
let stepDate =
|
|
14499
|
+
let stepDate = DateTime.fromTimestamp(_startDate.getTime());
|
|
14401
14500
|
let timeStepDate = stepDate.getTime();
|
|
14402
14501
|
const unitDay = Math.sign(_numDays);
|
|
14403
14502
|
let stepDay = Math.abs(_numDays);
|
|
@@ -14463,7 +14562,7 @@ const MONTH_START = {
|
|
|
14463
14562
|
const _startDate = toJsDate(date);
|
|
14464
14563
|
const yStart = _startDate.getFullYear();
|
|
14465
14564
|
const mStart = _startDate.getMonth();
|
|
14466
|
-
const jsDate = new
|
|
14565
|
+
const jsDate = new DateTime(yStart, mStart, 1);
|
|
14467
14566
|
return jsDateToRoundNumber(jsDate);
|
|
14468
14567
|
},
|
|
14469
14568
|
};
|
|
@@ -14507,7 +14606,7 @@ const QUARTER_START = {
|
|
|
14507
14606
|
compute: function (date) {
|
|
14508
14607
|
const quarter = QUARTER.compute(date);
|
|
14509
14608
|
const year = YEAR.compute(date);
|
|
14510
|
-
const jsDate = new
|
|
14609
|
+
const jsDate = new DateTime(year, (quarter - 1) * 3, 1);
|
|
14511
14610
|
return jsDateToRoundNumber(jsDate);
|
|
14512
14611
|
},
|
|
14513
14612
|
};
|
|
@@ -14524,7 +14623,7 @@ const QUARTER_END = {
|
|
|
14524
14623
|
compute: function (date) {
|
|
14525
14624
|
const quarter = QUARTER.compute(date);
|
|
14526
14625
|
const year = YEAR.compute(date);
|
|
14527
|
-
const jsDate = new
|
|
14626
|
+
const jsDate = new DateTime(year, quarter * 3, 0);
|
|
14528
14627
|
return jsDateToRoundNumber(jsDate);
|
|
14529
14628
|
},
|
|
14530
14629
|
};
|
|
@@ -14540,7 +14639,7 @@ const YEAR_START = {
|
|
|
14540
14639
|
computeFormat: () => "m/d/yyyy",
|
|
14541
14640
|
compute: function (date) {
|
|
14542
14641
|
const year = YEAR.compute(date);
|
|
14543
|
-
const jsDate = new
|
|
14642
|
+
const jsDate = new DateTime(year, 0, 1);
|
|
14544
14643
|
return jsDateToRoundNumber(jsDate);
|
|
14545
14644
|
},
|
|
14546
14645
|
};
|
|
@@ -14556,7 +14655,7 @@ const YEAR_END = {
|
|
|
14556
14655
|
computeFormat: () => "m/d/yyyy",
|
|
14557
14656
|
compute: function (date) {
|
|
14558
14657
|
const year = YEAR.compute(date);
|
|
14559
|
-
const jsDate = new
|
|
14658
|
+
const jsDate = new DateTime(year + 1, 0, 0);
|
|
14560
14659
|
return jsDateToRoundNumber(jsDate);
|
|
14561
14660
|
},
|
|
14562
14661
|
};
|
|
@@ -14690,7 +14789,7 @@ function assertDeprecationFactorStrictlyPositive(factor) {
|
|
|
14690
14789
|
function assertSettlementLessThanOneYearBeforeMaturity(settlement, maturity) {
|
|
14691
14790
|
const startDate = toJsDate(settlement);
|
|
14692
14791
|
const endDate = toJsDate(maturity);
|
|
14693
|
-
const startDatePlusOneYear =
|
|
14792
|
+
const startDatePlusOneYear = toJsDate(settlement);
|
|
14694
14793
|
startDatePlusOneYear.setFullYear(startDate.getFullYear() + 1);
|
|
14695
14794
|
assert(() => endDate.getTime() <= startDatePlusOneYear.getTime(), _lt("The settlement date (%s) must at most one year after the maturity date (%s).", settlement.toString(), maturity.toString()));
|
|
14696
14795
|
}
|
|
@@ -40428,9 +40527,10 @@ class RangeAdapter {
|
|
|
40428
40527
|
* Get a Xc string that represent a part of a range
|
|
40429
40528
|
*/
|
|
40430
40529
|
getRangePartString(range, part) {
|
|
40431
|
-
|
|
40530
|
+
var _a, _b;
|
|
40531
|
+
const colFixed = range.parts && ((_a = range.parts[part]) === null || _a === void 0 ? void 0 : _a.colFixed) ? "$" : "";
|
|
40432
40532
|
const col = part === 0 ? numberToLetters(range.zone.left) : numberToLetters(range.zone.right);
|
|
40433
|
-
const rowFixed = range.parts && range.parts[part].rowFixed ? "$" : "";
|
|
40533
|
+
const rowFixed = range.parts && ((_b = range.parts[part]) === null || _b === void 0 ? void 0 : _b.rowFixed) ? "$" : "";
|
|
40434
40534
|
const row = part === 0 ? String(range.zone.top + 1) : String(range.zone.bottom + 1);
|
|
40435
40535
|
let str = "";
|
|
40436
40536
|
if (range.isFullCol) {
|
|
@@ -43071,6 +43171,6 @@ exports.setTranslationMethod = setTranslationMethod;
|
|
|
43071
43171
|
exports.tokenize = tokenize;
|
|
43072
43172
|
|
|
43073
43173
|
|
|
43074
|
-
__info__.version = '16.0.
|
|
43075
|
-
__info__.date = '2024-01-
|
|
43076
|
-
__info__.hash = '
|
|
43174
|
+
__info__.version = '16.0.29';
|
|
43175
|
+
__info__.date = '2024-01-17T10:24:52.885Z';
|
|
43176
|
+
__info__.hash = '3fda985';
|
package/dist/o-spreadsheet.d.ts
CHANGED
|
@@ -243,6 +243,33 @@ declare function toCartesian(xc: string): Position$1;
|
|
|
243
243
|
*/
|
|
244
244
|
declare function toXC(col: HeaderIndex, row: HeaderIndex, rangePart?: RangePart): string;
|
|
245
245
|
|
|
246
|
+
/**
|
|
247
|
+
* A DateTime object that can be used to manipulate spreadsheet dates.
|
|
248
|
+
* Conceptually, a spreadsheet date is simply a number with a date format,
|
|
249
|
+
* and it is timezone-agnostic.
|
|
250
|
+
* This DateTime object consistently uses UTC time to represent a naive date and time.
|
|
251
|
+
*/
|
|
252
|
+
declare class DateTime {
|
|
253
|
+
private jsDate;
|
|
254
|
+
constructor(year: number, month: number, day: number, hours?: number, minutes?: number, seconds?: number);
|
|
255
|
+
static fromTimestamp(timestamp: number): DateTime;
|
|
256
|
+
static now(): DateTime;
|
|
257
|
+
toString(): string;
|
|
258
|
+
getTime(): number;
|
|
259
|
+
getFullYear(): number;
|
|
260
|
+
getMonth(): number;
|
|
261
|
+
getDate(): number;
|
|
262
|
+
getDay(): number;
|
|
263
|
+
getHours(): number;
|
|
264
|
+
getMinutes(): number;
|
|
265
|
+
getSeconds(): number;
|
|
266
|
+
setFullYear(year: number): void;
|
|
267
|
+
setDate(date: number): void;
|
|
268
|
+
setHours(hours: number): void;
|
|
269
|
+
setMinutes(minutes: number): void;
|
|
270
|
+
setSeconds(seconds: number): void;
|
|
271
|
+
}
|
|
272
|
+
|
|
246
273
|
/**
|
|
247
274
|
* Formats a cell value with its format.
|
|
248
275
|
*/
|
|
@@ -6141,7 +6168,7 @@ declare class ChartPanel extends Component<Props$4, SpreadsheetChildEnv> {
|
|
|
6141
6168
|
declare function toNumber(value: string | number | boolean | null | undefined): number;
|
|
6142
6169
|
declare function toString(value: string | number | boolean | null | undefined): string;
|
|
6143
6170
|
declare function toBoolean(value: string | number | boolean | null | undefined): boolean;
|
|
6144
|
-
declare function toJsDate(value: string | number | boolean | null | undefined):
|
|
6171
|
+
declare function toJsDate(value: string | number | boolean | null | undefined): DateTime;
|
|
6145
6172
|
|
|
6146
6173
|
/**
|
|
6147
6174
|
* This function is meant to be used as a tag for a template strings.
|