@bbn/bbn 2.0.64 → 2.0.66

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.
@@ -1,11 +1,8 @@
1
1
  import { Temporal } from 'temporal-polyfill';
2
2
  import bbnDt from './dt.js';
3
- import { BbnDtKind } from '../vars/types.js';
4
3
  export default class bbnDtDate extends bbnDt<Temporal.PlainDate> {
5
- #private;
6
- readonly kind: BbnDtKind;
4
+ readonly kind: bbnDtKind;
7
5
  constructor(y?: any, m?: number, d?: number);
8
6
  protected compareSameKind(other: this): -1 | 0 | 1;
9
- get value(): Temporal.PlainDate;
10
7
  fdate(long?: boolean, weekday?: boolean): string;
11
8
  }
@@ -1,48 +1,36 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _bbnDtDate_value;
13
1
  import { Temporal } from 'temporal-polyfill';
14
2
  import bbnDt from './dt.js';
15
- class bbnDtDate extends bbnDt {
3
+ export default class bbnDtDate extends bbnDt {
16
4
  constructor(y, m, d) {
17
- super();
18
- _bbnDtDate_value.set(this, void 0);
19
- this.kind = 'date';
5
+ let value;
20
6
  if (!y) {
21
- __classPrivateFieldSet(this, _bbnDtDate_value, Temporal.PlainDate.from(Temporal.Now.plainDateISO()), "f");
7
+ value = Temporal.PlainDate.from(Temporal.Now.plainDateISO());
22
8
  }
23
9
  else if (m === undefined) {
24
10
  if (y instanceof Temporal.PlainDate) {
25
- __classPrivateFieldSet(this, _bbnDtDate_value, y, "f");
11
+ value = y;
26
12
  }
27
13
  else if (y instanceof Date) {
28
- __classPrivateFieldSet(this, _bbnDtDate_value, new Temporal.PlainDate(y.getFullYear(), y.getMonth() + 1, y.getDate()), "f");
14
+ value = new Temporal.PlainDate(y.getFullYear(), y.getMonth() + 1, y.getDate());
29
15
  }
30
16
  else if (typeof y === 'number') {
31
17
  const d = new Date(y);
32
- __classPrivateFieldSet(this, _bbnDtDate_value, new Temporal.PlainDate(d.getFullYear(), d.getMonth() + 1, d.getDate()), "f");
18
+ value = new Temporal.PlainDate(d.getFullYear(), d.getMonth() + 1, d.getDate());
33
19
  }
34
20
  else {
35
21
  throw new Error('Invalid value for bbnDtDateTime');
36
22
  }
37
23
  }
24
+ else {
25
+ value = new Temporal.PlainDate(y, m, d || 1);
26
+ }
27
+ super(value);
28
+ this.kind = 'date';
38
29
  }
39
30
  compareSameKind(other) {
40
- const cmp = Temporal.PlainDate.compare(__classPrivateFieldGet(this, _bbnDtDate_value, "f"), other.value);
31
+ const cmp = Temporal.PlainDate.compare(this.value, other.value);
41
32
  return (cmp < 0 ? -1 : cmp > 0 ? 1 : 0);
42
33
  }
43
- get value() {
44
- return __classPrivateFieldGet(this, _bbnDtDate_value, "f");
45
- }
46
34
  fdate(long = false, weekday = false) {
47
35
  const date = new Date(this.year(), this.month() - 1, this.day());
48
36
  const opt = Object.assign({ year: 'numeric', month: long ? 'long' : 'numeric', day: 'numeric' }, (weekday ? { weekday: (long ? 'long' : 'short') } : {}));
@@ -50,6 +38,4 @@ class bbnDtDate extends bbnDt {
50
38
  return d.format(date);
51
39
  }
52
40
  }
53
- _bbnDtDate_value = new WeakMap();
54
- export default bbnDtDate;
55
41
  ;
@@ -1,11 +1,8 @@
1
1
  import { Temporal } from 'temporal-polyfill';
2
- import { BbnDtKind } from '../vars/types.js';
3
2
  import bbnDt from './dt.js';
4
3
  export default class bbnDtDateTime extends bbnDt<Temporal.PlainDateTime> {
5
- #private;
6
- readonly kind: BbnDtKind;
4
+ readonly kind: bbnDtKind;
7
5
  constructor(y?: any, m?: number, d?: number, h?: number, i?: number, s?: number, ms?: number);
8
- get value(): Temporal.PlainDateTime;
9
6
  fdate(long?: boolean, withTime?: boolean, weekday?: boolean): string;
10
7
  ftime(withSeconds?: boolean): string;
11
8
  }
@@ -1,46 +1,31 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _bbnDtDateTime_value;
13
1
  import { Temporal } from 'temporal-polyfill';
14
2
  import bbnDt from './dt.js';
15
- class bbnDtDateTime extends bbnDt {
3
+ export default class bbnDtDateTime extends bbnDt {
16
4
  constructor(y, m, d, h, i, s, ms) {
17
- super();
18
- _bbnDtDateTime_value.set(this, void 0);
19
- this.kind = 'datetime';
5
+ let value;
20
6
  if (!y) {
21
- __classPrivateFieldSet(this, _bbnDtDateTime_value, Temporal.PlainDateTime.from(Temporal.Now.plainDateISO()), "f");
7
+ value = Temporal.PlainDateTime.from(Temporal.Now.plainDateISO());
22
8
  }
23
9
  else if (m === undefined) {
24
10
  if (y instanceof Temporal.PlainDateTime) {
25
- __classPrivateFieldSet(this, _bbnDtDateTime_value, y, "f");
11
+ value = y;
26
12
  }
27
13
  else if (y instanceof Date) {
28
- __classPrivateFieldSet(this, _bbnDtDateTime_value, new Temporal.PlainDateTime(y.getFullYear(), y.getMonth() + 1, y.getDate(), y.getHours(), y.getMinutes(), y.getSeconds(), y.getMilliseconds()), "f");
14
+ value = new Temporal.PlainDateTime(y.getFullYear(), y.getMonth() + 1, y.getDate(), y.getHours(), y.getMinutes(), y.getSeconds(), y.getMilliseconds());
29
15
  }
30
16
  else if (typeof y === 'number') {
31
17
  const d = new Date(y);
32
- __classPrivateFieldSet(this, _bbnDtDateTime_value, new Temporal.PlainDateTime(d.getFullYear(), d.getMonth() + 1, d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds()), "f");
18
+ value = new Temporal.PlainDateTime(d.getFullYear(), d.getMonth() + 1, d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());
33
19
  }
34
20
  else {
35
21
  throw new Error('Invalid value for bbnDtDateTime');
36
22
  }
37
23
  }
38
24
  else {
39
- __classPrivateFieldSet(this, _bbnDtDateTime_value, new Temporal.PlainDateTime(y, m, d || 1, h || 0, i || 0, s || 0, ms || 0), "f");
25
+ value = new Temporal.PlainDateTime(y, m, d || 1, h || 0, i || 0, s || 0, ms || 0);
40
26
  }
41
- }
42
- get value() {
43
- return __classPrivateFieldGet(this, _bbnDtDateTime_value, "f");
27
+ super(value);
28
+ this.kind = 'datetime';
44
29
  }
45
30
  fdate(long = false, withTime = false, weekday = false) {
46
31
  if (!this.value) {
@@ -67,6 +52,4 @@ class bbnDtDateTime extends bbnDt {
67
52
  return t.format(date);
68
53
  }
69
54
  }
70
- _bbnDtDateTime_value = new WeakMap();
71
- export default bbnDtDateTime;
72
55
  ;
@@ -1,8 +1,10 @@
1
- import { BbnDtKind, BbnDtTemporal } from '../vars/types.js';
1
+ import { bbnDtTemporal } from '../vars/types.js';
2
2
  import bbnDtDuration from './duration.js';
3
- export declare abstract class bbnDt<TValue extends BbnDtTemporal> {
4
- abstract readonly kind: BbnDtKind;
5
- abstract get value(): TValue;
3
+ export declare abstract class bbnDt<TValue extends bbnDtTemporal> {
4
+ #private;
5
+ abstract readonly kind: bbnDtKind;
6
+ constructor(value?: TValue);
7
+ get value(): TValue | undefined;
6
8
  static compare(a: any, b: any, unit: string | undefined): -1 | 0 | 1;
7
9
  static parse(input: string, format: string | string[], cls?: 'auto' | 'zoned' | 'dateTime' | 'date' | 'time' | 'yearMonth' | 'monthDay', locale?: {
8
10
  monthsLong?: string[];
@@ -12,24 +14,24 @@ export declare abstract class bbnDt<TValue extends BbnDtTemporal> {
12
14
  }): bbnDt<any>;
13
15
  parse(input: string, format: string): bbnDt<any>;
14
16
  compare(other: any, unit?: string): -1 | 0 | 1;
15
- add(amount: number | bbnDtDuration | object, unit?: string): TValue;
16
- subtract(amount: number | bbnDtDuration | object, unit?: string): TValue;
17
+ add(amount: number | bbnDtDuration | object, unit?: string): bbnDt<any>;
18
+ subtract(amount: number | bbnDtDuration | object, unit?: string): bbnDt<any>;
17
19
  isBefore(other: bbnDt<any>): boolean;
18
20
  isAfter(other: bbnDt<any>): boolean;
19
21
  isSame(other: bbnDt<any>): boolean;
20
22
  equals(other: bbnDt<any>): boolean;
21
23
  toJSON(): {
22
- kind: BbnDtKind;
24
+ kind: bbnDtKind;
23
25
  value: string;
24
26
  };
25
27
  toString(): string;
26
- year(v?: any): number | TValue;
27
- month(v?: any): number | TValue;
28
- day(v?: any): number | TValue;
29
- hour(v?: any): number | TValue;
30
- minute(v?: any): number | TValue;
31
- second(v?: any): number | TValue;
32
- weekday(v?: any, past?: any): number | TValue;
28
+ year(v?: any): number | bbnDt<any>;
29
+ month(v?: any): number | bbnDt<any>;
30
+ day(v?: any): number | bbnDt<any>;
31
+ hour(v?: any): number | bbnDt<any>;
32
+ minute(v?: any): number | bbnDt<any>;
33
+ second(v?: any): number | bbnDt<any>;
34
+ weekday(v?: any, past?: any): number | bbnDt<any>;
33
35
  date(v?: any): string | bbnDt<any>;
34
36
  datetime(v?: any): string | bbnDt<any>;
35
37
  time(v?: any): string | bbnDt<any>;
@@ -65,6 +67,6 @@ export declare abstract class bbnDt<TValue extends BbnDtTemporal> {
65
67
  * @param {boolean} past - If true → return previous occurrence instead of next.
66
68
  * @param {string} [locale] - Optional locale for weekday names.
67
69
  */
68
- setWeekday(weekday: number | string, past?: boolean, locale?: string): TValue;
70
+ setWeekday(weekday: number | string, past?: boolean, locale?: string): bbnDt<any>;
69
71
  }
70
72
  export default bbnDt;
@@ -1,3 +1,15 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _bbnDt_value;
1
13
  import { Temporal } from 'temporal-polyfill';
2
14
  import substr from '../../fn/string/substr.js';
3
15
  import { getWeekdayIndex, getWeekday } from '../functions/getWeekday.js';
@@ -5,9 +17,16 @@ import { unitsCorrespondence, formatsMap } from '../vars/units.js';
5
17
  import each from '../../fn/loop/each.js';
6
18
  import isPrimitive from '../../fn/type/isPrimitive.js';
7
19
  import bbnDtDuration from './duration.js';
8
- import parse from '../functions/parse.js';
9
20
  import camelToCss from '../../fn/string/camelToCss.js';
10
21
  export class bbnDt {
22
+ constructor(value) {
23
+ _bbnDt_value.set(this, void 0);
24
+ __classPrivateFieldSet(this, _bbnDt_value, value, "f");
25
+ }
26
+ get value() {
27
+ return __classPrivateFieldGet(this, _bbnDt_value, "f");
28
+ }
29
+ ;
11
30
  static compare(a, b, unit) {
12
31
  if (!a || !b) {
13
32
  throw new TypeError('Both arguments must be Temporal values');
@@ -447,4 +466,5 @@ export class bbnDt {
447
466
  return this.add(diff, 'd');
448
467
  }
449
468
  }
469
+ _bbnDt_value = new WeakMap();
450
470
  export default bbnDt;
@@ -1,10 +1,7 @@
1
1
  import { Temporal } from 'temporal-polyfill';
2
- import { BbnDtKind } from '../vars/types.js';
3
2
  import bbnDt from './dt.js';
4
3
  export default class bbnDtMonthDay extends bbnDt<Temporal.PlainMonthDay> {
5
- #private;
6
- readonly kind: BbnDtKind;
4
+ readonly kind: bbnDtKind;
7
5
  constructor(m?: any, d?: number);
8
- get value(): Temporal.PlainMonthDay;
9
6
  fdate(long?: boolean, withTime?: boolean, weekday?: boolean): string;
10
7
  }
@@ -1,47 +1,32 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _bbnDtMonthDay_value;
13
1
  import { Temporal } from 'temporal-polyfill';
14
2
  import bbnDt from './dt.js';
15
- class bbnDtMonthDay extends bbnDt {
3
+ export default class bbnDtMonthDay extends bbnDt {
16
4
  constructor(m, d) {
17
- super();
18
- _bbnDtMonthDay_value.set(this, void 0);
19
- this.kind = 'month-day';
5
+ let value;
20
6
  if (!m) {
21
7
  const d = new Date();
22
- __classPrivateFieldSet(this, _bbnDtMonthDay_value, new Temporal.PlainMonthDay(d.getMonth() + 1, d.getDate()), "f");
8
+ value = new Temporal.PlainMonthDay(d.getMonth() + 1, d.getDate());
23
9
  }
24
10
  else if (d === undefined) {
25
11
  if (m instanceof Temporal.PlainMonthDay) {
26
- __classPrivateFieldSet(this, _bbnDtMonthDay_value, m, "f");
12
+ value = m;
27
13
  }
28
14
  else if (m instanceof Date) {
29
- __classPrivateFieldSet(this, _bbnDtMonthDay_value, new Temporal.PlainMonthDay(m.getMonth() + 1, m.getDate()), "f");
15
+ value = new Temporal.PlainMonthDay(m.getMonth() + 1, m.getDate());
30
16
  }
31
17
  else if (typeof m === 'number') {
32
18
  const d = new Date(m);
33
- __classPrivateFieldSet(this, _bbnDtMonthDay_value, new Temporal.PlainMonthDay(d.getMonth() + 1, d.getDate()), "f");
19
+ value = new Temporal.PlainMonthDay(d.getMonth() + 1, d.getDate());
34
20
  }
35
21
  else {
36
22
  throw new Error('Invalid value for bbnDtDateTime');
37
23
  }
38
24
  }
39
25
  else {
40
- __classPrivateFieldSet(this, _bbnDtMonthDay_value, new Temporal.PlainMonthDay(m, d), "f");
26
+ value = new Temporal.PlainMonthDay(m, d);
41
27
  }
42
- }
43
- get value() {
44
- return __classPrivateFieldGet(this, _bbnDtMonthDay_value, "f");
28
+ super(value);
29
+ this.kind = 'month-day';
45
30
  }
46
31
  fdate(long = false, withTime = false, weekday = false) {
47
32
  if (!this.value) {
@@ -56,6 +41,4 @@ class bbnDtMonthDay extends bbnDt {
56
41
  return d.format(date);
57
42
  }
58
43
  }
59
- _bbnDtMonthDay_value = new WeakMap();
60
- export default bbnDtMonthDay;
61
44
  ;
@@ -1,9 +1,7 @@
1
1
  import { Temporal } from 'temporal-polyfill';
2
2
  import bbnDt from './dt.js';
3
3
  export default class bbnDtTime extends bbnDt<Temporal.PlainTime> {
4
- #private;
5
4
  readonly kind: 'time';
6
5
  constructor(h?: any, i?: number, s?: number, ms?: number);
7
- get value(): Temporal.PlainTime;
8
6
  ftime(withSeconds?: boolean): string;
9
7
  }
@@ -1,49 +1,37 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _bbnDtTime_value;
13
1
  import { Temporal } from 'temporal-polyfill';
14
2
  import bbnDt from './dt.js';
15
- class bbnDtTime extends bbnDt {
3
+ export default class bbnDtTime extends bbnDt {
16
4
  constructor(h, i, s, ms) {
17
- super();
18
- _bbnDtTime_value.set(this, void 0);
19
- this.kind = 'time';
5
+ let value;
20
6
  if (!h) {
21
7
  const d = new Date();
22
- __classPrivateFieldSet(this, _bbnDtTime_value, new Temporal.PlainTime(d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds() * 1000000), "f");
8
+ value = new Temporal.PlainTime(d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds() * 1000000);
23
9
  }
24
10
  else if (h === undefined) {
25
11
  if (h instanceof Temporal.PlainTime) {
26
- __classPrivateFieldSet(this, _bbnDtTime_value, h, "f");
12
+ value = h;
27
13
  }
28
14
  else if (h instanceof Date) {
29
- __classPrivateFieldSet(this, _bbnDtTime_value, new Temporal.PlainTime(h.getHours(), h.getMinutes(), h.getSeconds(), h.getMilliseconds() * 1000000), "f");
15
+ value = new Temporal.PlainTime(h.getHours(), h.getMinutes(), h.getSeconds(), h.getMilliseconds() * 1000000);
30
16
  }
31
17
  else if (typeof h === 'number') {
32
18
  if (i !== undefined) {
33
- __classPrivateFieldSet(this, _bbnDtTime_value, new Temporal.PlainTime(h, i, s || 0, ms || 0), "f");
19
+ value = new Temporal.PlainTime(h, i, s || 0, ms || 0);
34
20
  }
35
21
  else {
36
22
  const d = new Date(h);
37
- __classPrivateFieldSet(this, _bbnDtTime_value, new Temporal.PlainTime(d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds() * 1000000), "f");
23
+ value = new Temporal.PlainTime(d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds() * 1000000);
38
24
  }
39
25
  }
40
26
  else {
41
27
  throw new Error('Invalid value for bbnDtDateTime');
42
28
  }
43
29
  }
44
- }
45
- get value() {
46
- return __classPrivateFieldGet(this, _bbnDtTime_value, "f");
30
+ else {
31
+ value = new Temporal.PlainTime(h, i || 0, s || 0, ms || 0);
32
+ }
33
+ super(value);
34
+ this.kind = 'time';
47
35
  }
48
36
  ftime(withSeconds = false) {
49
37
  if (!this.value) {
@@ -61,6 +49,4 @@ class bbnDtTime extends bbnDt {
61
49
  return t.format(date);
62
50
  }
63
51
  }
64
- _bbnDtTime_value = new WeakMap();
65
- export default bbnDtTime;
66
52
  ;
@@ -1,10 +1,7 @@
1
1
  import { Temporal } from 'temporal-polyfill';
2
- import { BbnDtKind } from '../vars/types.js';
3
- import { bbnDt } from './dt.js';
2
+ import bbnDt from './dt.js';
4
3
  export default class bbnDtYearMonth extends bbnDt<Temporal.PlainYearMonth> {
5
- #private;
6
- readonly kind: BbnDtKind;
4
+ readonly kind: bbnDtKind;
7
5
  constructor(y?: any, m?: number);
8
- get value(): Temporal.PlainYearMonth;
9
6
  fdate(long?: boolean, withTime?: boolean, weekday?: boolean): string;
10
7
  }
@@ -1,44 +1,32 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _bbnDtYearMonth_value;
13
1
  import { Temporal } from 'temporal-polyfill';
14
- import { bbnDt } from './dt.js';
15
- class bbnDtYearMonth extends bbnDt {
2
+ import bbnDt from './dt.js';
3
+ export default class bbnDtYearMonth extends bbnDt {
16
4
  constructor(y, m) {
17
- super();
18
- _bbnDtYearMonth_value.set(this, void 0);
19
- this.kind = 'year-month';
5
+ let value;
20
6
  if (!y) {
21
7
  const d = new Date();
22
- __classPrivateFieldSet(this, _bbnDtYearMonth_value, new Temporal.PlainYearMonth(d.getFullYear(), d.getMonth() + 1), "f");
8
+ value = new Temporal.PlainYearMonth(d.getFullYear(), d.getMonth() + 1);
23
9
  }
24
10
  else if (m === undefined) {
25
11
  if (y instanceof Temporal.PlainYearMonth) {
26
- __classPrivateFieldSet(this, _bbnDtYearMonth_value, y, "f");
12
+ value = y;
27
13
  }
28
14
  else if (y instanceof Date) {
29
- __classPrivateFieldSet(this, _bbnDtYearMonth_value, new Temporal.PlainYearMonth(y.getFullYear(), y.getMonth() + 1), "f");
15
+ value = new Temporal.PlainYearMonth(y.getFullYear(), y.getMonth() + 1);
30
16
  }
31
17
  else if (typeof m === 'number') {
32
18
  const d = new Date(m);
33
- __classPrivateFieldSet(this, _bbnDtYearMonth_value, new Temporal.PlainYearMonth(d.getFullYear(), d.getMonth() + 1), "f");
19
+ value = new Temporal.PlainYearMonth(d.getFullYear(), d.getMonth() + 1);
34
20
  }
35
21
  else {
36
22
  throw new Error('Invalid value for bbnDtDateTime');
37
23
  }
38
24
  }
39
- }
40
- get value() {
41
- return __classPrivateFieldGet(this, _bbnDtYearMonth_value, "f");
25
+ else {
26
+ value = new Temporal.PlainYearMonth(y, m);
27
+ }
28
+ super(value);
29
+ this.kind = 'year-month';
42
30
  }
43
31
  fdate(long = false, withTime = false, weekday = false) {
44
32
  if (!this.value) {
@@ -53,6 +41,4 @@ class bbnDtYearMonth extends bbnDt {
53
41
  return d.format(date);
54
42
  }
55
43
  }
56
- _bbnDtYearMonth_value = new WeakMap();
57
- export default bbnDtYearMonth;
58
44
  ;
@@ -1,11 +1,8 @@
1
1
  import { Temporal } from 'temporal-polyfill';
2
- import { BbnDtKind } from '../vars/types.js';
3
2
  import bbnDt from './dt.js';
4
3
  export default class bbnDtZoned extends bbnDt<Temporal.ZonedDateTime> {
5
- #private;
6
- readonly kind: BbnDtKind;
4
+ readonly kind: bbnDtKind;
7
5
  constructor(z?: any, y?: any, m?: number, d?: number, h?: number, i?: number, s?: number, ms?: number);
8
- get value(): Temporal.ZonedDateTime;
9
6
  fdate(long?: boolean, withTime?: boolean, weekday?: boolean): string;
10
7
  ftime(withSeconds?: boolean): string;
11
8
  }
@@ -1,37 +1,23 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _bbnDtZoned_value;
13
1
  import { Temporal } from 'temporal-polyfill';
14
2
  import fromJsDate from '../functions/fromJsDate.js';
15
3
  import bbnDt from './dt.js';
16
- class bbnDtZoned extends bbnDt {
4
+ export default class bbnDtZoned extends bbnDt {
17
5
  constructor(z, y, m, d, h, i, s, ms) {
18
- super();
19
- _bbnDtZoned_value.set(this, void 0);
20
- this.kind = 'zoned';
6
+ let value;
21
7
  if (!z) {
22
8
  const date = new Date();
23
- __classPrivateFieldSet(this, _bbnDtZoned_value, new Temporal.ZonedDateTime(BigInt(date.getTime() * 1000000), Intl.DateTimeFormat().resolvedOptions().timeZone), "f");
9
+ value = new Temporal.ZonedDateTime(BigInt(date.getTime() * 1000000), Intl.DateTimeFormat().resolvedOptions().timeZone);
24
10
  }
25
11
  else if (y === undefined) {
26
12
  if (z instanceof Temporal.ZonedDateTime) {
27
- __classPrivateFieldSet(this, _bbnDtZoned_value, z, "f");
13
+ value = z;
28
14
  }
29
15
  else if (z instanceof Date) {
30
- __classPrivateFieldSet(this, _bbnDtZoned_value, fromJsDate(z, true), "f");
16
+ value = fromJsDate(z, true);
31
17
  }
32
18
  else if (typeof z === 'number') {
33
19
  const d = new Date(z);
34
- __classPrivateFieldSet(this, _bbnDtZoned_value, fromJsDate(d, true), "f");
20
+ value = fromJsDate(d, true);
35
21
  }
36
22
  else {
37
23
  throw new Error('Invalid value for bbnDtZoned');
@@ -39,11 +25,10 @@ class bbnDtZoned extends bbnDt {
39
25
  }
40
26
  else {
41
27
  const dt = new Temporal.PlainDateTime(y, m, d || 1, h || 0, i || 0, s || 0, ms || 0);
42
- __classPrivateFieldSet(this, _bbnDtZoned_value, dt.toZonedDateTime(z || Temporal.Now.timeZoneId()), "f");
28
+ value = dt.toZonedDateTime(z || Temporal.Now.timeZoneId());
43
29
  }
44
- }
45
- get value() {
46
- return __classPrivateFieldGet(this, _bbnDtZoned_value, "f");
30
+ super(value);
31
+ this.kind = 'zoned';
47
32
  }
48
33
  fdate(long = false, withTime = false, weekday = false) {
49
34
  if (!this.value) {
@@ -70,5 +55,3 @@ class bbnDtZoned extends bbnDt {
70
55
  return t.format(date);
71
56
  }
72
57
  }
73
- _bbnDtZoned_value = new WeakMap();
74
- export default bbnDtZoned;
@@ -1,12 +1,6 @@
1
- import bbnDtZoned from '../classes/zoned.js';
2
- import bbnDtDateTime from '../classes/dateTime.js';
3
- import bbnDtDate from '../classes/date.js';
4
- import bbnDtTime from '../classes/time.js';
5
- import bbnDtYearMonth from '../classes/yearMonth.js';
6
- import bbnDtMonthDay from '../classes/monthDay.js';
7
1
  export default function parse(input: string, format: string | string[], cls?: 'auto' | 'zoned' | 'dateTime' | 'date' | 'time' | 'yearMonth' | 'monthDay', locale?: {
8
2
  monthsLong?: string[];
9
3
  monthsShort?: string[];
10
4
  weekdaysLong?: string[];
11
5
  weekdaysShort?: string[];
12
- }): bbnDtZoned | bbnDtDateTime | bbnDtDate | bbnDtTime | bbnDtYearMonth | bbnDtMonthDay;
6
+ }): bbnDt<any>;
@@ -1,3 +1,2 @@
1
1
  import { Temporal } from 'temporal-polyfill';
2
- export type BbnDtKind = 'datetime' | 'date' | 'time' | 'year-month' | 'month-day' | 'zoned';
3
- export type BbnDtTemporal = Temporal.PlainDateTime | Temporal.PlainDate | Temporal.PlainTime | Temporal.PlainYearMonth | Temporal.PlainMonthDay | Temporal.ZonedDateTime;
2
+ export type bbnDtTemporal = Temporal.PlainDateTime | Temporal.PlainDate | Temporal.PlainTime | Temporal.PlainYearMonth | Temporal.PlainMonthDay | Temporal.ZonedDateTime;
package/dist/dt.d.ts CHANGED
@@ -2,7 +2,7 @@ import bbnDtDateTime from './dt/classes/dateTime.js';
2
2
  import parse from './dt/functions/parse.js';
3
3
  import guessFormat from './dt/functions/guessFormat.js';
4
4
  declare const dt: {
5
- (value: any, inputFormat?: null | String, cls?: "auto" | "zoned" | "dateTime" | "date" | "time" | "yearMonth" | "monthDay"): import("./dt/classes/zoned.js").default | import("./dt/classes/date.js").default | import("./dt/classes/time.js").default | import("./dt/classes/yearMonth.js").default | import("./dt/classes/monthDay.js").default | bbnDtDateTime;
5
+ (value: any, inputFormat?: null | String, cls?: "auto" | "zoned" | "dateTime" | "date" | "time" | "yearMonth" | "monthDay"): bbnDt<any> | bbnDtDateTime;
6
6
  locales: any;
7
7
  parse: typeof parse;
8
8
  guessFormat: typeof guessFormat;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "2.0.64",
3
+ "version": "2.0.66",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",