@bbn/bbn 2.0.79 → 2.0.81
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/bbn.js +1 -1
- package/dist/bbn.js.map +1 -1
- package/dist/dt.d.ts +2 -1
- package/dist/dt.js +33 -1
- package/package.json +1 -1
package/dist/dt.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import bbnDtDuration from './dt/classes/duration.js';
|
|
1
2
|
import parse from './dt/functions/parse.js';
|
|
2
3
|
import guessFormat from './dt/functions/guessFormat.js';
|
|
3
4
|
declare const dt: {
|
|
@@ -8,7 +9,7 @@ declare const dt: {
|
|
|
8
9
|
time(): void;
|
|
9
10
|
date(): void;
|
|
10
11
|
dateTime(): void;
|
|
11
|
-
duration():
|
|
12
|
+
duration(amount: any, unit: any): bbnDtDuration;
|
|
12
13
|
zoned(): void;
|
|
13
14
|
monthDay(): void;
|
|
14
15
|
yearMonth(): void;
|
package/dist/dt.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
import { Temporal } from 'temporal-polyfill';
|
|
1
2
|
import bbnDtDateTime from './dt/classes/dateTime.js';
|
|
3
|
+
import bbnDtDate from './dt/classes/date.js';
|
|
4
|
+
import bbnDtTime from './dt/classes/zoned.js';
|
|
5
|
+
import bbnDtYearMonth from './dt/classes/yearMonth.js';
|
|
6
|
+
import bbnDtMonthDay from './dt/classes/monthDay.js';
|
|
7
|
+
import bbnDtZoned from './dt/classes/zoned.js';
|
|
8
|
+
import bbnDtDuration from './dt/classes/duration.js';
|
|
2
9
|
import _ from './_.js';
|
|
3
10
|
import parse from './dt/functions/parse.js';
|
|
4
11
|
import guessFormat from './dt/functions/guessFormat.js';
|
|
12
|
+
import getRow from './fn/object/getRow.js';
|
|
5
13
|
const patterns = [
|
|
6
14
|
// MariaDB DATETIME "YYYY-MM-DD HH:MM:SS"
|
|
7
15
|
{
|
|
@@ -220,6 +228,27 @@ const dt = (value, inputFormat = null, cls = 'auto') => {
|
|
|
220
228
|
const d = value;
|
|
221
229
|
return new bbnDtDateTime(d.getFullYear(), d.getMonth() + 1, d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());
|
|
222
230
|
}
|
|
231
|
+
else if (value instanceof Temporal.PlainDateTime) {
|
|
232
|
+
return new bbnDtDateTime(value);
|
|
233
|
+
}
|
|
234
|
+
else if (value instanceof Temporal.PlainDate) {
|
|
235
|
+
return new bbnDtDate(value);
|
|
236
|
+
}
|
|
237
|
+
else if (value instanceof Temporal.PlainTime) {
|
|
238
|
+
return new bbnDtTime(value);
|
|
239
|
+
}
|
|
240
|
+
else if (value instanceof Temporal.PlainYearMonth) {
|
|
241
|
+
return new bbnDtYearMonth(value);
|
|
242
|
+
}
|
|
243
|
+
else if (value instanceof Temporal.PlainMonthDay) {
|
|
244
|
+
return new bbnDtMonthDay(value);
|
|
245
|
+
}
|
|
246
|
+
else if (value instanceof Temporal.ZonedDateTime) {
|
|
247
|
+
return new bbnDtZoned(value);
|
|
248
|
+
}
|
|
249
|
+
else if (value instanceof Temporal.Duration) {
|
|
250
|
+
return new bbnDtDuration(value);
|
|
251
|
+
}
|
|
223
252
|
else {
|
|
224
253
|
return { isValid: false };
|
|
225
254
|
}
|
|
@@ -231,7 +260,10 @@ dt.guessFormat = guessFormat;
|
|
|
231
260
|
dt.time = () => { };
|
|
232
261
|
dt.date = () => { };
|
|
233
262
|
dt.dateTime = () => { };
|
|
234
|
-
dt.duration = () => {
|
|
263
|
+
dt.duration = (amount, unit) => {
|
|
264
|
+
const realUnit = unitsCorrespondence[unit] ? getRow(units, d => d[0] === unitsCorrespondence[unit])[1] || undefined : undefined;
|
|
265
|
+
return new bbnDtDuration(Temporal.Duration.from({ [realUnit + 's']: amount }));
|
|
266
|
+
};
|
|
235
267
|
dt.zoned = () => { };
|
|
236
268
|
dt.monthDay = () => { };
|
|
237
269
|
dt.yearMonth = () => { };
|