@bbn/bbn 2.0.80 → 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/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(): void;
12
+ duration(amount: any, unit: any): bbnDtDuration;
12
13
  zoned(): void;
13
14
  monthDay(): void;
14
15
  yearMonth(): void;
package/dist/dt.js CHANGED
@@ -9,6 +9,7 @@ import bbnDtDuration from './dt/classes/duration.js';
9
9
  import _ from './_.js';
10
10
  import parse from './dt/functions/parse.js';
11
11
  import guessFormat from './dt/functions/guessFormat.js';
12
+ import getRow from './fn/object/getRow.js';
12
13
  const patterns = [
13
14
  // MariaDB DATETIME "YYYY-MM-DD HH:MM:SS"
14
15
  {
@@ -259,7 +260,10 @@ dt.guessFormat = guessFormat;
259
260
  dt.time = () => { };
260
261
  dt.date = () => { };
261
262
  dt.dateTime = () => { };
262
- 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
+ };
263
267
  dt.zoned = () => { };
264
268
  dt.monthDay = () => { };
265
269
  dt.yearMonth = () => { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "2.0.80",
3
+ "version": "2.0.81",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",