@odoo/o-spreadsheet 15.0.14 → 15.0.15
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 +91 -34
- package/dist/o-spreadsheet.esm.js +91 -34
- package/dist/o-spreadsheet.iife.js +91 -34
- package/dist/o-spreadsheet.iife.min.js +363 -363
- package/package.json +1 -1
|
@@ -129,14 +129,72 @@ const FORMULA_REF_IDENTIFIER = "|";
|
|
|
129
129
|
// -----------------------------------------------------------------------------
|
|
130
130
|
// Date Type
|
|
131
131
|
// -----------------------------------------------------------------------------
|
|
132
|
+
/**
|
|
133
|
+
* A DateTime object that can be used to manipulate spreadsheet dates.
|
|
134
|
+
* Conceptually, a spreadsheet date is simply a number with a date format,
|
|
135
|
+
* and it is timezone-agnostic.
|
|
136
|
+
* This DateTime object consistently uses UTC time to represent a naive date and time.
|
|
137
|
+
*/
|
|
138
|
+
class DateTime {
|
|
139
|
+
constructor(year, month, day, hours = 0, minutes = 0, seconds = 0) {
|
|
140
|
+
this.jsDate = new Date(Date.UTC(year, month, day, hours, minutes, seconds, 0));
|
|
141
|
+
}
|
|
142
|
+
static fromTimestamp(timestamp) {
|
|
143
|
+
const date = new Date(timestamp);
|
|
144
|
+
return new DateTime(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
|
|
145
|
+
}
|
|
146
|
+
static now() {
|
|
147
|
+
const now = new Date();
|
|
148
|
+
return new DateTime(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes(), now.getSeconds());
|
|
149
|
+
}
|
|
150
|
+
toString() {
|
|
151
|
+
return this.jsDate.toString();
|
|
152
|
+
}
|
|
153
|
+
getTime() {
|
|
154
|
+
return this.jsDate.getTime();
|
|
155
|
+
}
|
|
156
|
+
getFullYear() {
|
|
157
|
+
return this.jsDate.getUTCFullYear();
|
|
158
|
+
}
|
|
159
|
+
getMonth() {
|
|
160
|
+
return this.jsDate.getUTCMonth();
|
|
161
|
+
}
|
|
162
|
+
getDate() {
|
|
163
|
+
return this.jsDate.getUTCDate();
|
|
164
|
+
}
|
|
165
|
+
getDay() {
|
|
166
|
+
return this.jsDate.getUTCDay();
|
|
167
|
+
}
|
|
168
|
+
getHours() {
|
|
169
|
+
return this.jsDate.getUTCHours();
|
|
170
|
+
}
|
|
171
|
+
getMinutes() {
|
|
172
|
+
return this.jsDate.getUTCMinutes();
|
|
173
|
+
}
|
|
174
|
+
getSeconds() {
|
|
175
|
+
return this.jsDate.getUTCSeconds();
|
|
176
|
+
}
|
|
177
|
+
setDate(date) {
|
|
178
|
+
this.jsDate.setUTCDate(date);
|
|
179
|
+
}
|
|
180
|
+
setHours(hours) {
|
|
181
|
+
this.jsDate.setUTCHours(hours);
|
|
182
|
+
}
|
|
183
|
+
setMinutes(minutes) {
|
|
184
|
+
this.jsDate.setUTCMinutes(minutes);
|
|
185
|
+
}
|
|
186
|
+
setSeconds(seconds) {
|
|
187
|
+
this.jsDate.setUTCSeconds(seconds);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
132
190
|
// -----------------------------------------------------------------------------
|
|
133
191
|
// Parsing
|
|
134
192
|
// -----------------------------------------------------------------------------
|
|
135
193
|
const CURRENT_MILLENIAL = 2000; // note: don't forget to update this in 2999
|
|
136
|
-
const CURRENT_YEAR =
|
|
137
|
-
const INITIAL_1900_DAY$1 = new
|
|
138
|
-
const INITIAL_JS_DAY =
|
|
139
|
-
const DATE_JS_1900_OFFSET = INITIAL_JS_DAY - INITIAL_1900_DAY$1;
|
|
194
|
+
const CURRENT_YEAR = DateTime.now().getFullYear();
|
|
195
|
+
const INITIAL_1900_DAY$1 = new DateTime(1899, 11, 30);
|
|
196
|
+
const INITIAL_JS_DAY = DateTime.fromTimestamp(0);
|
|
197
|
+
const DATE_JS_1900_OFFSET = INITIAL_JS_DAY.getTime() - INITIAL_1900_DAY$1.getTime();
|
|
140
198
|
const mdyDateRegexp = /^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/;
|
|
141
199
|
const ymdDateRegexp = /^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/;
|
|
142
200
|
const timeRegexp = /((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;
|
|
@@ -176,7 +234,7 @@ function parseDateTime(str) {
|
|
|
176
234
|
return {
|
|
177
235
|
value: date.value + time.value,
|
|
178
236
|
format: date.format + " " + (time.format === "hhhh:mm:ss" ? "hh:mm:ss" : time.format),
|
|
179
|
-
jsDate: new
|
|
237
|
+
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()),
|
|
180
238
|
};
|
|
181
239
|
}
|
|
182
240
|
return date || time;
|
|
@@ -193,13 +251,13 @@ function parseDate(str, dateFormat) {
|
|
|
193
251
|
const day = Number(parts[dayIndex]);
|
|
194
252
|
const leadingZero = (parts[monthIndex].length === 2 && month < 10) || (parts[dayIndex].length === 2 && day < 10);
|
|
195
253
|
const year = parts[yearIndex] ? inferYear(parts[yearIndex]) : CURRENT_YEAR;
|
|
196
|
-
const jsDate = new
|
|
254
|
+
const jsDate = new DateTime(year, month - 1, day);
|
|
197
255
|
const sep = str.match(/\/|-|\s/)[0];
|
|
198
256
|
if (jsDate.getMonth() !== month - 1 || jsDate.getDate() !== day) {
|
|
199
257
|
// invalid date
|
|
200
258
|
return null;
|
|
201
259
|
}
|
|
202
|
-
const delta = jsDate - INITIAL_1900_DAY$1;
|
|
260
|
+
const delta = jsDate.getTime() - INITIAL_1900_DAY$1.getTime();
|
|
203
261
|
let format = leadingZero ? `mm${sep}dd` : `m${sep}d`;
|
|
204
262
|
if (parts[yearIndex]) {
|
|
205
263
|
format = isMDY ? format + sep + "yyyy" : "yyyy" + sep + format;
|
|
@@ -259,7 +317,7 @@ function parseTime(str) {
|
|
|
259
317
|
if (hours >= 24) {
|
|
260
318
|
format = "hhhh:mm:ss";
|
|
261
319
|
}
|
|
262
|
-
const jsDate = new
|
|
320
|
+
const jsDate = new DateTime(1899, 11, 30, hours, minutes, seconds);
|
|
263
321
|
return {
|
|
264
322
|
value: hours / 24 + minutes / 1440 + seconds / 86400,
|
|
265
323
|
format: format,
|
|
@@ -273,7 +331,7 @@ function parseTime(str) {
|
|
|
273
331
|
// -----------------------------------------------------------------------------
|
|
274
332
|
function numberToJsDate(value) {
|
|
275
333
|
const truncValue = Math.trunc(value);
|
|
276
|
-
let date =
|
|
334
|
+
let date = DateTime.fromTimestamp(truncValue * 86400 * 1000 - DATE_JS_1900_OFFSET);
|
|
277
335
|
let time = value - truncValue;
|
|
278
336
|
time = time < 0 ? 1 + time : time;
|
|
279
337
|
const hours = Math.round(time * 24);
|
|
@@ -346,7 +404,7 @@ function formatJSTime(jsDate, format) {
|
|
|
346
404
|
.map((p) => {
|
|
347
405
|
switch (p) {
|
|
348
406
|
case "hhhh":
|
|
349
|
-
const helapsedHours = Math.floor((jsDate.getTime() - INITIAL_1900_DAY$1) / (60 * 60 * 1000));
|
|
407
|
+
const helapsedHours = Math.floor((jsDate.getTime() - INITIAL_1900_DAY$1.getTime()) / (60 * 60 * 1000));
|
|
350
408
|
return helapsedHours.toString();
|
|
351
409
|
case "hh":
|
|
352
410
|
return hours.toString().padStart(2, "0");
|
|
@@ -2846,7 +2904,7 @@ function isBoolean(str) {
|
|
|
2846
2904
|
function isDateTime(str) {
|
|
2847
2905
|
return parseDateTime(str) !== null;
|
|
2848
2906
|
}
|
|
2849
|
-
const MARKDOWN_LINK_REGEX = /^\[(
|
|
2907
|
+
const MARKDOWN_LINK_REGEX = /^\[(.+)\]\((.+)\)$/;
|
|
2850
2908
|
//link must start with http or https
|
|
2851
2909
|
//https://stackoverflow.com/a/3809435/4760614
|
|
2852
2910
|
const WEB_LINK_REGEX = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;
|
|
@@ -4749,7 +4807,7 @@ var database = /*#__PURE__*/Object.freeze({
|
|
|
4749
4807
|
DVARP: DVARP
|
|
4750
4808
|
});
|
|
4751
4809
|
|
|
4752
|
-
const INITIAL_1900_DAY = new
|
|
4810
|
+
const INITIAL_1900_DAY = new DateTime(1899, 11, 30);
|
|
4753
4811
|
const DEFAULT_TYPE = 1;
|
|
4754
4812
|
const DEFAULT_WEEKEND = 1;
|
|
4755
4813
|
function isLeapYear(year) {
|
|
@@ -4778,7 +4836,7 @@ const DATE = {
|
|
|
4778
4836
|
if (_year < 1900) {
|
|
4779
4837
|
_year += 1900;
|
|
4780
4838
|
}
|
|
4781
|
-
const jsDate = new
|
|
4839
|
+
const jsDate = new DateTime(_year, _month - 1, _day);
|
|
4782
4840
|
const delta = jsDate.getTime() - INITIAL_1900_DAY.getTime();
|
|
4783
4841
|
assert(() => delta >= 0, _lt(`The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.`));
|
|
4784
4842
|
return Math.round(delta / 86400000);
|
|
@@ -4851,7 +4909,7 @@ const EDATE = {
|
|
|
4851
4909
|
const yStart = _startDate.getFullYear();
|
|
4852
4910
|
const mStart = _startDate.getMonth();
|
|
4853
4911
|
const dStart = _startDate.getDate();
|
|
4854
|
-
const jsDate = new
|
|
4912
|
+
const jsDate = new DateTime(yStart, mStart + _months, dStart);
|
|
4855
4913
|
const delta = jsDate.getTime() - INITIAL_1900_DAY.getTime();
|
|
4856
4914
|
return Math.round(delta / 86400000);
|
|
4857
4915
|
},
|
|
@@ -4873,7 +4931,7 @@ const EOMONTH = {
|
|
|
4873
4931
|
const _months = Math.trunc(toNumber(months));
|
|
4874
4932
|
const yStart = _startDate.getFullYear();
|
|
4875
4933
|
const mStart = _startDate.getMonth();
|
|
4876
|
-
const jsDate = new
|
|
4934
|
+
const jsDate = new DateTime(yStart, mStart + _months + 1, 0);
|
|
4877
4935
|
const delta = jsDate.getTime() - INITIAL_1900_DAY.getTime();
|
|
4878
4936
|
return Math.round(delta / 86400000);
|
|
4879
4937
|
},
|
|
@@ -4913,17 +4971,17 @@ const ISOWEEKNUM = {
|
|
|
4913
4971
|
// The first week of the year is the week that contains the first
|
|
4914
4972
|
// Thursday of the year.
|
|
4915
4973
|
let firstThursday = 1;
|
|
4916
|
-
while (new
|
|
4974
|
+
while (new DateTime(y, 0, firstThursday).getDay() !== 4) {
|
|
4917
4975
|
firstThursday += 1;
|
|
4918
4976
|
}
|
|
4919
|
-
const firstDayOfFirstWeek = new
|
|
4977
|
+
const firstDayOfFirstWeek = new DateTime(y, 0, firstThursday - 3);
|
|
4920
4978
|
// The last week of the year is the week that contains the last Thursday of
|
|
4921
4979
|
// the year.
|
|
4922
4980
|
let lastThursday = 31;
|
|
4923
|
-
while (new
|
|
4981
|
+
while (new DateTime(y, 11, lastThursday).getDay() !== 4) {
|
|
4924
4982
|
lastThursday -= 1;
|
|
4925
4983
|
}
|
|
4926
|
-
const lastDayOfLastWeek = new
|
|
4984
|
+
const lastDayOfLastWeek = new DateTime(y, 11, lastThursday + 3);
|
|
4927
4985
|
// B - If our date > lastDayOfLastWeek then it's in the weeks of the year after
|
|
4928
4986
|
// If our date < firstDayOfFirstWeek then it's in the weeks of the year before
|
|
4929
4987
|
let offsetYear;
|
|
@@ -4949,17 +5007,17 @@ const ISOWEEKNUM = {
|
|
|
4949
5007
|
case 1:
|
|
4950
5008
|
// firstDay is the 1st day of the 1st week of the year after
|
|
4951
5009
|
// firstDay = lastDayOfLastWeek + 1 Day
|
|
4952
|
-
firstDay = new
|
|
5010
|
+
firstDay = new DateTime(y, 11, lastThursday + 3 + 1);
|
|
4953
5011
|
break;
|
|
4954
5012
|
case -1:
|
|
4955
5013
|
// firstDay is the 1st day of the 1st week of the previous year.
|
|
4956
5014
|
// The first week of the previous year is the week that contains the
|
|
4957
5015
|
// first Thursday of the previous year.
|
|
4958
5016
|
let firstThursdayPreviousYear = 1;
|
|
4959
|
-
while (new
|
|
5017
|
+
while (new DateTime(y - 1, 0, firstThursdayPreviousYear).getDay() !== 4) {
|
|
4960
5018
|
firstThursdayPreviousYear += 1;
|
|
4961
5019
|
}
|
|
4962
|
-
firstDay = new
|
|
5020
|
+
firstDay = new DateTime(y - 1, 0, firstThursdayPreviousYear - 3);
|
|
4963
5021
|
break;
|
|
4964
5022
|
}
|
|
4965
5023
|
const dif = (_date.getTime() - firstDay.getTime()) / 86400000;
|
|
@@ -5098,8 +5156,8 @@ const NETWORKDAYS_INTL = {
|
|
|
5098
5156
|
});
|
|
5099
5157
|
}
|
|
5100
5158
|
const invertDate = _startDate.getTime() > _endDate.getTime();
|
|
5101
|
-
const stopDate =
|
|
5102
|
-
let stepDate =
|
|
5159
|
+
const stopDate = DateTime.fromTimestamp((invertDate ? _startDate : _endDate).getTime());
|
|
5160
|
+
let stepDate = DateTime.fromTimestamp((invertDate ? _endDate : _startDate).getTime());
|
|
5103
5161
|
const timeStopDate = stopDate.getTime();
|
|
5104
5162
|
let timeStepDate = stepDate.getTime();
|
|
5105
5163
|
let netWorkingDay = 0;
|
|
@@ -5123,8 +5181,7 @@ const NOW = {
|
|
|
5123
5181
|
returns: ["DATE"],
|
|
5124
5182
|
returnFormat: { specificFormat: "m/d/yyyy hh:mm:ss" },
|
|
5125
5183
|
compute: function () {
|
|
5126
|
-
let today =
|
|
5127
|
-
today.setMilliseconds(0);
|
|
5184
|
+
let today = DateTime.now();
|
|
5128
5185
|
const delta = today.getTime() - INITIAL_1900_DAY.getTime();
|
|
5129
5186
|
const time = today.getHours() / 24 + today.getMinutes() / 1440 + today.getSeconds() / 86400;
|
|
5130
5187
|
return Math.floor(delta / 86400000) + time;
|
|
@@ -5198,8 +5255,8 @@ const TODAY = {
|
|
|
5198
5255
|
returns: ["DATE"],
|
|
5199
5256
|
returnFormat: { specificFormat: "m/d/yyyy" },
|
|
5200
5257
|
compute: function () {
|
|
5201
|
-
const today =
|
|
5202
|
-
const jsDate = new
|
|
5258
|
+
const today = DateTime.now();
|
|
5259
|
+
const jsDate = new DateTime(today.getFullYear(), today.getMonth(), today.getDate());
|
|
5203
5260
|
const delta = jsDate.getTime() - INITIAL_1900_DAY.getTime();
|
|
5204
5261
|
return Math.round(delta / 86400000);
|
|
5205
5262
|
},
|
|
@@ -5255,10 +5312,10 @@ const WEEKNUM = {
|
|
|
5255
5312
|
}
|
|
5256
5313
|
const y = _date.getFullYear();
|
|
5257
5314
|
let dayStart = 1;
|
|
5258
|
-
let startDayOfFirstWeek = new
|
|
5315
|
+
let startDayOfFirstWeek = new DateTime(y, 0, dayStart);
|
|
5259
5316
|
while (startDayOfFirstWeek.getDay() !== startDayOfWeek) {
|
|
5260
5317
|
dayStart += 1;
|
|
5261
|
-
startDayOfFirstWeek = new
|
|
5318
|
+
startDayOfFirstWeek = new DateTime(y, 0, dayStart);
|
|
5262
5319
|
}
|
|
5263
5320
|
const dif = (_date.getTime() - startDayOfFirstWeek.getTime()) / 86400000;
|
|
5264
5321
|
if (dif < 0) {
|
|
@@ -5312,7 +5369,7 @@ const WORKDAY_INTL = {
|
|
|
5312
5369
|
timesHoliday.add(holiday.getTime());
|
|
5313
5370
|
});
|
|
5314
5371
|
}
|
|
5315
|
-
let stepDate =
|
|
5372
|
+
let stepDate = DateTime.fromTimestamp(_startDate.getTime());
|
|
5316
5373
|
let timeStepDate = stepDate.getTime();
|
|
5317
5374
|
const unitDay = Math.sign(_numDays);
|
|
5318
5375
|
let stepDay = Math.abs(_numDays);
|
|
@@ -31450,6 +31507,6 @@ exports.registries = registries;
|
|
|
31450
31507
|
exports.setTranslationMethod = setTranslationMethod;
|
|
31451
31508
|
|
|
31452
31509
|
|
|
31453
|
-
__info__.version = '15.0.
|
|
31454
|
-
__info__.date = '
|
|
31455
|
-
__info__.hash = '
|
|
31510
|
+
__info__.version = '15.0.15';
|
|
31511
|
+
__info__.date = '2024-01-12T13:39:45.422Z';
|
|
31512
|
+
__info__.hash = 'c87764c';
|
|
@@ -106,14 +106,72 @@ const FORMULA_REF_IDENTIFIER = "|";
|
|
|
106
106
|
// -----------------------------------------------------------------------------
|
|
107
107
|
// Date Type
|
|
108
108
|
// -----------------------------------------------------------------------------
|
|
109
|
+
/**
|
|
110
|
+
* A DateTime object that can be used to manipulate spreadsheet dates.
|
|
111
|
+
* Conceptually, a spreadsheet date is simply a number with a date format,
|
|
112
|
+
* and it is timezone-agnostic.
|
|
113
|
+
* This DateTime object consistently uses UTC time to represent a naive date and time.
|
|
114
|
+
*/
|
|
115
|
+
class DateTime {
|
|
116
|
+
constructor(year, month, day, hours = 0, minutes = 0, seconds = 0) {
|
|
117
|
+
this.jsDate = new Date(Date.UTC(year, month, day, hours, minutes, seconds, 0));
|
|
118
|
+
}
|
|
119
|
+
static fromTimestamp(timestamp) {
|
|
120
|
+
const date = new Date(timestamp);
|
|
121
|
+
return new DateTime(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
|
|
122
|
+
}
|
|
123
|
+
static now() {
|
|
124
|
+
const now = new Date();
|
|
125
|
+
return new DateTime(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes(), now.getSeconds());
|
|
126
|
+
}
|
|
127
|
+
toString() {
|
|
128
|
+
return this.jsDate.toString();
|
|
129
|
+
}
|
|
130
|
+
getTime() {
|
|
131
|
+
return this.jsDate.getTime();
|
|
132
|
+
}
|
|
133
|
+
getFullYear() {
|
|
134
|
+
return this.jsDate.getUTCFullYear();
|
|
135
|
+
}
|
|
136
|
+
getMonth() {
|
|
137
|
+
return this.jsDate.getUTCMonth();
|
|
138
|
+
}
|
|
139
|
+
getDate() {
|
|
140
|
+
return this.jsDate.getUTCDate();
|
|
141
|
+
}
|
|
142
|
+
getDay() {
|
|
143
|
+
return this.jsDate.getUTCDay();
|
|
144
|
+
}
|
|
145
|
+
getHours() {
|
|
146
|
+
return this.jsDate.getUTCHours();
|
|
147
|
+
}
|
|
148
|
+
getMinutes() {
|
|
149
|
+
return this.jsDate.getUTCMinutes();
|
|
150
|
+
}
|
|
151
|
+
getSeconds() {
|
|
152
|
+
return this.jsDate.getUTCSeconds();
|
|
153
|
+
}
|
|
154
|
+
setDate(date) {
|
|
155
|
+
this.jsDate.setUTCDate(date);
|
|
156
|
+
}
|
|
157
|
+
setHours(hours) {
|
|
158
|
+
this.jsDate.setUTCHours(hours);
|
|
159
|
+
}
|
|
160
|
+
setMinutes(minutes) {
|
|
161
|
+
this.jsDate.setUTCMinutes(minutes);
|
|
162
|
+
}
|
|
163
|
+
setSeconds(seconds) {
|
|
164
|
+
this.jsDate.setUTCSeconds(seconds);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
109
167
|
// -----------------------------------------------------------------------------
|
|
110
168
|
// Parsing
|
|
111
169
|
// -----------------------------------------------------------------------------
|
|
112
170
|
const CURRENT_MILLENIAL = 2000; // note: don't forget to update this in 2999
|
|
113
|
-
const CURRENT_YEAR =
|
|
114
|
-
const INITIAL_1900_DAY$1 = new
|
|
115
|
-
const INITIAL_JS_DAY =
|
|
116
|
-
const DATE_JS_1900_OFFSET = INITIAL_JS_DAY - INITIAL_1900_DAY$1;
|
|
171
|
+
const CURRENT_YEAR = DateTime.now().getFullYear();
|
|
172
|
+
const INITIAL_1900_DAY$1 = new DateTime(1899, 11, 30);
|
|
173
|
+
const INITIAL_JS_DAY = DateTime.fromTimestamp(0);
|
|
174
|
+
const DATE_JS_1900_OFFSET = INITIAL_JS_DAY.getTime() - INITIAL_1900_DAY$1.getTime();
|
|
117
175
|
const mdyDateRegexp = /^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/;
|
|
118
176
|
const ymdDateRegexp = /^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/;
|
|
119
177
|
const timeRegexp = /((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;
|
|
@@ -153,7 +211,7 @@ function parseDateTime(str) {
|
|
|
153
211
|
return {
|
|
154
212
|
value: date.value + time.value,
|
|
155
213
|
format: date.format + " " + (time.format === "hhhh:mm:ss" ? "hh:mm:ss" : time.format),
|
|
156
|
-
jsDate: new
|
|
214
|
+
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()),
|
|
157
215
|
};
|
|
158
216
|
}
|
|
159
217
|
return date || time;
|
|
@@ -170,13 +228,13 @@ function parseDate(str, dateFormat) {
|
|
|
170
228
|
const day = Number(parts[dayIndex]);
|
|
171
229
|
const leadingZero = (parts[monthIndex].length === 2 && month < 10) || (parts[dayIndex].length === 2 && day < 10);
|
|
172
230
|
const year = parts[yearIndex] ? inferYear(parts[yearIndex]) : CURRENT_YEAR;
|
|
173
|
-
const jsDate = new
|
|
231
|
+
const jsDate = new DateTime(year, month - 1, day);
|
|
174
232
|
const sep = str.match(/\/|-|\s/)[0];
|
|
175
233
|
if (jsDate.getMonth() !== month - 1 || jsDate.getDate() !== day) {
|
|
176
234
|
// invalid date
|
|
177
235
|
return null;
|
|
178
236
|
}
|
|
179
|
-
const delta = jsDate - INITIAL_1900_DAY$1;
|
|
237
|
+
const delta = jsDate.getTime() - INITIAL_1900_DAY$1.getTime();
|
|
180
238
|
let format = leadingZero ? `mm${sep}dd` : `m${sep}d`;
|
|
181
239
|
if (parts[yearIndex]) {
|
|
182
240
|
format = isMDY ? format + sep + "yyyy" : "yyyy" + sep + format;
|
|
@@ -236,7 +294,7 @@ function parseTime(str) {
|
|
|
236
294
|
if (hours >= 24) {
|
|
237
295
|
format = "hhhh:mm:ss";
|
|
238
296
|
}
|
|
239
|
-
const jsDate = new
|
|
297
|
+
const jsDate = new DateTime(1899, 11, 30, hours, minutes, seconds);
|
|
240
298
|
return {
|
|
241
299
|
value: hours / 24 + minutes / 1440 + seconds / 86400,
|
|
242
300
|
format: format,
|
|
@@ -250,7 +308,7 @@ function parseTime(str) {
|
|
|
250
308
|
// -----------------------------------------------------------------------------
|
|
251
309
|
function numberToJsDate(value) {
|
|
252
310
|
const truncValue = Math.trunc(value);
|
|
253
|
-
let date =
|
|
311
|
+
let date = DateTime.fromTimestamp(truncValue * 86400 * 1000 - DATE_JS_1900_OFFSET);
|
|
254
312
|
let time = value - truncValue;
|
|
255
313
|
time = time < 0 ? 1 + time : time;
|
|
256
314
|
const hours = Math.round(time * 24);
|
|
@@ -323,7 +381,7 @@ function formatJSTime(jsDate, format) {
|
|
|
323
381
|
.map((p) => {
|
|
324
382
|
switch (p) {
|
|
325
383
|
case "hhhh":
|
|
326
|
-
const helapsedHours = Math.floor((jsDate.getTime() - INITIAL_1900_DAY$1) / (60 * 60 * 1000));
|
|
384
|
+
const helapsedHours = Math.floor((jsDate.getTime() - INITIAL_1900_DAY$1.getTime()) / (60 * 60 * 1000));
|
|
327
385
|
return helapsedHours.toString();
|
|
328
386
|
case "hh":
|
|
329
387
|
return hours.toString().padStart(2, "0");
|
|
@@ -2823,7 +2881,7 @@ function isBoolean(str) {
|
|
|
2823
2881
|
function isDateTime(str) {
|
|
2824
2882
|
return parseDateTime(str) !== null;
|
|
2825
2883
|
}
|
|
2826
|
-
const MARKDOWN_LINK_REGEX = /^\[(
|
|
2884
|
+
const MARKDOWN_LINK_REGEX = /^\[(.+)\]\((.+)\)$/;
|
|
2827
2885
|
//link must start with http or https
|
|
2828
2886
|
//https://stackoverflow.com/a/3809435/4760614
|
|
2829
2887
|
const WEB_LINK_REGEX = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;
|
|
@@ -4726,7 +4784,7 @@ var database = /*#__PURE__*/Object.freeze({
|
|
|
4726
4784
|
DVARP: DVARP
|
|
4727
4785
|
});
|
|
4728
4786
|
|
|
4729
|
-
const INITIAL_1900_DAY = new
|
|
4787
|
+
const INITIAL_1900_DAY = new DateTime(1899, 11, 30);
|
|
4730
4788
|
const DEFAULT_TYPE = 1;
|
|
4731
4789
|
const DEFAULT_WEEKEND = 1;
|
|
4732
4790
|
function isLeapYear(year) {
|
|
@@ -4755,7 +4813,7 @@ const DATE = {
|
|
|
4755
4813
|
if (_year < 1900) {
|
|
4756
4814
|
_year += 1900;
|
|
4757
4815
|
}
|
|
4758
|
-
const jsDate = new
|
|
4816
|
+
const jsDate = new DateTime(_year, _month - 1, _day);
|
|
4759
4817
|
const delta = jsDate.getTime() - INITIAL_1900_DAY.getTime();
|
|
4760
4818
|
assert(() => delta >= 0, _lt(`The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.`));
|
|
4761
4819
|
return Math.round(delta / 86400000);
|
|
@@ -4828,7 +4886,7 @@ const EDATE = {
|
|
|
4828
4886
|
const yStart = _startDate.getFullYear();
|
|
4829
4887
|
const mStart = _startDate.getMonth();
|
|
4830
4888
|
const dStart = _startDate.getDate();
|
|
4831
|
-
const jsDate = new
|
|
4889
|
+
const jsDate = new DateTime(yStart, mStart + _months, dStart);
|
|
4832
4890
|
const delta = jsDate.getTime() - INITIAL_1900_DAY.getTime();
|
|
4833
4891
|
return Math.round(delta / 86400000);
|
|
4834
4892
|
},
|
|
@@ -4850,7 +4908,7 @@ const EOMONTH = {
|
|
|
4850
4908
|
const _months = Math.trunc(toNumber(months));
|
|
4851
4909
|
const yStart = _startDate.getFullYear();
|
|
4852
4910
|
const mStart = _startDate.getMonth();
|
|
4853
|
-
const jsDate = new
|
|
4911
|
+
const jsDate = new DateTime(yStart, mStart + _months + 1, 0);
|
|
4854
4912
|
const delta = jsDate.getTime() - INITIAL_1900_DAY.getTime();
|
|
4855
4913
|
return Math.round(delta / 86400000);
|
|
4856
4914
|
},
|
|
@@ -4890,17 +4948,17 @@ const ISOWEEKNUM = {
|
|
|
4890
4948
|
// The first week of the year is the week that contains the first
|
|
4891
4949
|
// Thursday of the year.
|
|
4892
4950
|
let firstThursday = 1;
|
|
4893
|
-
while (new
|
|
4951
|
+
while (new DateTime(y, 0, firstThursday).getDay() !== 4) {
|
|
4894
4952
|
firstThursday += 1;
|
|
4895
4953
|
}
|
|
4896
|
-
const firstDayOfFirstWeek = new
|
|
4954
|
+
const firstDayOfFirstWeek = new DateTime(y, 0, firstThursday - 3);
|
|
4897
4955
|
// The last week of the year is the week that contains the last Thursday of
|
|
4898
4956
|
// the year.
|
|
4899
4957
|
let lastThursday = 31;
|
|
4900
|
-
while (new
|
|
4958
|
+
while (new DateTime(y, 11, lastThursday).getDay() !== 4) {
|
|
4901
4959
|
lastThursday -= 1;
|
|
4902
4960
|
}
|
|
4903
|
-
const lastDayOfLastWeek = new
|
|
4961
|
+
const lastDayOfLastWeek = new DateTime(y, 11, lastThursday + 3);
|
|
4904
4962
|
// B - If our date > lastDayOfLastWeek then it's in the weeks of the year after
|
|
4905
4963
|
// If our date < firstDayOfFirstWeek then it's in the weeks of the year before
|
|
4906
4964
|
let offsetYear;
|
|
@@ -4926,17 +4984,17 @@ const ISOWEEKNUM = {
|
|
|
4926
4984
|
case 1:
|
|
4927
4985
|
// firstDay is the 1st day of the 1st week of the year after
|
|
4928
4986
|
// firstDay = lastDayOfLastWeek + 1 Day
|
|
4929
|
-
firstDay = new
|
|
4987
|
+
firstDay = new DateTime(y, 11, lastThursday + 3 + 1);
|
|
4930
4988
|
break;
|
|
4931
4989
|
case -1:
|
|
4932
4990
|
// firstDay is the 1st day of the 1st week of the previous year.
|
|
4933
4991
|
// The first week of the previous year is the week that contains the
|
|
4934
4992
|
// first Thursday of the previous year.
|
|
4935
4993
|
let firstThursdayPreviousYear = 1;
|
|
4936
|
-
while (new
|
|
4994
|
+
while (new DateTime(y - 1, 0, firstThursdayPreviousYear).getDay() !== 4) {
|
|
4937
4995
|
firstThursdayPreviousYear += 1;
|
|
4938
4996
|
}
|
|
4939
|
-
firstDay = new
|
|
4997
|
+
firstDay = new DateTime(y - 1, 0, firstThursdayPreviousYear - 3);
|
|
4940
4998
|
break;
|
|
4941
4999
|
}
|
|
4942
5000
|
const dif = (_date.getTime() - firstDay.getTime()) / 86400000;
|
|
@@ -5075,8 +5133,8 @@ const NETWORKDAYS_INTL = {
|
|
|
5075
5133
|
});
|
|
5076
5134
|
}
|
|
5077
5135
|
const invertDate = _startDate.getTime() > _endDate.getTime();
|
|
5078
|
-
const stopDate =
|
|
5079
|
-
let stepDate =
|
|
5136
|
+
const stopDate = DateTime.fromTimestamp((invertDate ? _startDate : _endDate).getTime());
|
|
5137
|
+
let stepDate = DateTime.fromTimestamp((invertDate ? _endDate : _startDate).getTime());
|
|
5080
5138
|
const timeStopDate = stopDate.getTime();
|
|
5081
5139
|
let timeStepDate = stepDate.getTime();
|
|
5082
5140
|
let netWorkingDay = 0;
|
|
@@ -5100,8 +5158,7 @@ const NOW = {
|
|
|
5100
5158
|
returns: ["DATE"],
|
|
5101
5159
|
returnFormat: { specificFormat: "m/d/yyyy hh:mm:ss" },
|
|
5102
5160
|
compute: function () {
|
|
5103
|
-
let today =
|
|
5104
|
-
today.setMilliseconds(0);
|
|
5161
|
+
let today = DateTime.now();
|
|
5105
5162
|
const delta = today.getTime() - INITIAL_1900_DAY.getTime();
|
|
5106
5163
|
const time = today.getHours() / 24 + today.getMinutes() / 1440 + today.getSeconds() / 86400;
|
|
5107
5164
|
return Math.floor(delta / 86400000) + time;
|
|
@@ -5175,8 +5232,8 @@ const TODAY = {
|
|
|
5175
5232
|
returns: ["DATE"],
|
|
5176
5233
|
returnFormat: { specificFormat: "m/d/yyyy" },
|
|
5177
5234
|
compute: function () {
|
|
5178
|
-
const today =
|
|
5179
|
-
const jsDate = new
|
|
5235
|
+
const today = DateTime.now();
|
|
5236
|
+
const jsDate = new DateTime(today.getFullYear(), today.getMonth(), today.getDate());
|
|
5180
5237
|
const delta = jsDate.getTime() - INITIAL_1900_DAY.getTime();
|
|
5181
5238
|
return Math.round(delta / 86400000);
|
|
5182
5239
|
},
|
|
@@ -5232,10 +5289,10 @@ const WEEKNUM = {
|
|
|
5232
5289
|
}
|
|
5233
5290
|
const y = _date.getFullYear();
|
|
5234
5291
|
let dayStart = 1;
|
|
5235
|
-
let startDayOfFirstWeek = new
|
|
5292
|
+
let startDayOfFirstWeek = new DateTime(y, 0, dayStart);
|
|
5236
5293
|
while (startDayOfFirstWeek.getDay() !== startDayOfWeek) {
|
|
5237
5294
|
dayStart += 1;
|
|
5238
|
-
startDayOfFirstWeek = new
|
|
5295
|
+
startDayOfFirstWeek = new DateTime(y, 0, dayStart);
|
|
5239
5296
|
}
|
|
5240
5297
|
const dif = (_date.getTime() - startDayOfFirstWeek.getTime()) / 86400000;
|
|
5241
5298
|
if (dif < 0) {
|
|
@@ -5289,7 +5346,7 @@ const WORKDAY_INTL = {
|
|
|
5289
5346
|
timesHoliday.add(holiday.getTime());
|
|
5290
5347
|
});
|
|
5291
5348
|
}
|
|
5292
|
-
let stepDate =
|
|
5349
|
+
let stepDate = DateTime.fromTimestamp(_startDate.getTime());
|
|
5293
5350
|
let timeStepDate = stepDate.getTime();
|
|
5294
5351
|
const unitDay = Math.sign(_numDays);
|
|
5295
5352
|
let stepDay = Math.abs(_numDays);
|
|
@@ -31405,6 +31462,6 @@ const helpers = {
|
|
|
31405
31462
|
export { CommandResult, CorePlugin, DATETIME_FORMAT, DataSource, DispatchResult, Model, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, DEBUG as __DEBUG__, __info__, astToFormula, cellTypes, convertAstNodes, coreTypes, functionCache, helpers, invalidateEvaluationCommands, normalize, parse, readonlyAllowedCommands, registries, setTranslationMethod };
|
|
31406
31463
|
|
|
31407
31464
|
|
|
31408
|
-
__info__.version = '15.0.
|
|
31409
|
-
__info__.date = '
|
|
31410
|
-
__info__.hash = '
|
|
31465
|
+
__info__.version = '15.0.15';
|
|
31466
|
+
__info__.date = '2024-01-12T13:39:45.422Z';
|
|
31467
|
+
__info__.hash = 'c87764c';
|