@bbn/bbn 2.0.65 → 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,10 +1,8 @@
1
1
  import { Temporal } from 'temporal-polyfill';
2
- import { bbnDtKind } from '../vars/types.js';
2
+ import bbnDt from './dt.js';
3
3
  export default class bbnDtDate extends bbnDt<Temporal.PlainDate> {
4
- #private;
5
4
  readonly kind: bbnDtKind;
6
5
  constructor(y?: any, m?: number, d?: number);
7
6
  protected compareSameKind(other: this): -1 | 0 | 1;
8
- get value(): Temporal.PlainDate;
9
7
  fdate(long?: boolean, weekday?: boolean): string;
10
8
  }
@@ -1,47 +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
- class bbnDtDate extends bbnDt {
2
+ import bbnDt from './dt.js';
3
+ export default class bbnDtDate extends bbnDt {
15
4
  constructor(y, m, d) {
16
- super();
17
- _bbnDtDate_value.set(this, void 0);
18
- this.kind = 'date';
5
+ let value;
19
6
  if (!y) {
20
- __classPrivateFieldSet(this, _bbnDtDate_value, Temporal.PlainDate.from(Temporal.Now.plainDateISO()), "f");
7
+ value = Temporal.PlainDate.from(Temporal.Now.plainDateISO());
21
8
  }
22
9
  else if (m === undefined) {
23
10
  if (y instanceof Temporal.PlainDate) {
24
- __classPrivateFieldSet(this, _bbnDtDate_value, y, "f");
11
+ value = y;
25
12
  }
26
13
  else if (y instanceof Date) {
27
- __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());
28
15
  }
29
16
  else if (typeof y === 'number') {
30
17
  const d = new Date(y);
31
- __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());
32
19
  }
33
20
  else {
34
21
  throw new Error('Invalid value for bbnDtDateTime');
35
22
  }
36
23
  }
24
+ else {
25
+ value = new Temporal.PlainDate(y, m, d || 1);
26
+ }
27
+ super(value);
28
+ this.kind = 'date';
37
29
  }
38
30
  compareSameKind(other) {
39
- const cmp = Temporal.PlainDate.compare(__classPrivateFieldGet(this, _bbnDtDate_value, "f"), other.value);
31
+ const cmp = Temporal.PlainDate.compare(this.value, other.value);
40
32
  return (cmp < 0 ? -1 : cmp > 0 ? 1 : 0);
41
33
  }
42
- get value() {
43
- return __classPrivateFieldGet(this, _bbnDtDate_value, "f");
44
- }
45
34
  fdate(long = false, weekday = false) {
46
35
  const date = new Date(this.year(), this.month() - 1, this.day());
47
36
  const opt = Object.assign({ year: 'numeric', month: long ? 'long' : 'numeric', day: 'numeric' }, (weekday ? { weekday: (long ? 'long' : 'short') } : {}));
@@ -49,6 +38,4 @@ class bbnDtDate extends bbnDt {
49
38
  return d.format(date);
50
39
  }
51
40
  }
52
- _bbnDtDate_value = new WeakMap();
53
- export default bbnDtDate;
54
41
  ;
@@ -1,10 +1,8 @@
1
1
  import { Temporal } from 'temporal-polyfill';
2
- import { bbnDtKind } from '../vars/types.js';
2
+ import bbnDt from './dt.js';
3
3
  export default class bbnDtDateTime extends bbnDt<Temporal.PlainDateTime> {
4
- #private;
5
4
  readonly kind: bbnDtKind;
6
5
  constructor(y?: any, m?: number, d?: number, h?: number, i?: number, s?: number, ms?: number);
7
- get value(): Temporal.PlainDateTime;
8
6
  fdate(long?: boolean, withTime?: boolean, weekday?: boolean): string;
9
7
  ftime(withSeconds?: boolean): string;
10
8
  }
@@ -1,45 +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
- class bbnDtDateTime extends bbnDt {
2
+ import bbnDt from './dt.js';
3
+ export default class bbnDtDateTime extends bbnDt {
15
4
  constructor(y, m, d, h, i, s, ms) {
16
- super();
17
- _bbnDtDateTime_value.set(this, void 0);
18
- this.kind = 'datetime';
5
+ let value;
19
6
  if (!y) {
20
- __classPrivateFieldSet(this, _bbnDtDateTime_value, Temporal.PlainDateTime.from(Temporal.Now.plainDateISO()), "f");
7
+ value = Temporal.PlainDateTime.from(Temporal.Now.plainDateISO());
21
8
  }
22
9
  else if (m === undefined) {
23
10
  if (y instanceof Temporal.PlainDateTime) {
24
- __classPrivateFieldSet(this, _bbnDtDateTime_value, y, "f");
11
+ value = y;
25
12
  }
26
13
  else if (y instanceof Date) {
27
- __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());
28
15
  }
29
16
  else if (typeof y === 'number') {
30
17
  const d = new Date(y);
31
- __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());
32
19
  }
33
20
  else {
34
21
  throw new Error('Invalid value for bbnDtDateTime');
35
22
  }
36
23
  }
37
24
  else {
38
- __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);
39
26
  }
40
- }
41
- get value() {
42
- return __classPrivateFieldGet(this, _bbnDtDateTime_value, "f");
27
+ super(value);
28
+ this.kind = 'datetime';
43
29
  }
44
30
  fdate(long = false, withTime = false, weekday = false) {
45
31
  if (!this.value) {
@@ -66,6 +52,4 @@ class bbnDtDateTime extends bbnDt {
66
52
  return t.format(date);
67
53
  }
68
54
  }
69
- _bbnDtDateTime_value = new WeakMap();
70
- export default bbnDtDateTime;
71
55
  ;
@@ -0,0 +1,72 @@
1
+ import { bbnDtTemporal } from '../vars/types.js';
2
+ import bbnDtDuration from './duration.js';
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;
8
+ static compare(a: any, b: any, unit: string | undefined): -1 | 0 | 1;
9
+ static parse(input: string, format: string | string[], cls?: 'auto' | 'zoned' | 'dateTime' | 'date' | 'time' | 'yearMonth' | 'monthDay', locale?: {
10
+ monthsLong?: string[];
11
+ monthsShort?: string[];
12
+ weekdaysLong?: string[];
13
+ weekdaysShort?: string[];
14
+ }): bbnDt<any>;
15
+ parse(input: string, format: string): bbnDt<any>;
16
+ compare(other: any, unit?: string): -1 | 0 | 1;
17
+ add(amount: number | bbnDtDuration | object, unit?: string): bbnDt<any>;
18
+ subtract(amount: number | bbnDtDuration | object, unit?: string): bbnDt<any>;
19
+ isBefore(other: bbnDt<any>): boolean;
20
+ isAfter(other: bbnDt<any>): boolean;
21
+ isSame(other: bbnDt<any>): boolean;
22
+ equals(other: bbnDt<any>): boolean;
23
+ toJSON(): {
24
+ kind: bbnDtKind;
25
+ value: string;
26
+ };
27
+ toString(): string;
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>;
35
+ date(v?: any): string | bbnDt<any>;
36
+ datetime(v?: any): string | bbnDt<any>;
37
+ time(v?: any): string | bbnDt<any>;
38
+ week(): number;
39
+ get YYYY(): string;
40
+ get YY(): string;
41
+ get MMMM(): string;
42
+ get MMM(): string;
43
+ get MM(): string;
44
+ get M(): string;
45
+ get EE(): string;
46
+ get DD(): string;
47
+ get d(): string;
48
+ get dddd(): string;
49
+ get ddd(): string;
50
+ get D(): string;
51
+ get HH(): string;
52
+ get H(): string;
53
+ get II(): string;
54
+ get mm(): string;
55
+ get I(): string;
56
+ get SS(): string;
57
+ get S(): string;
58
+ get WW(): string;
59
+ get W(): string;
60
+ format(format?: string): string;
61
+ /**
62
+ * Returns a NEW date that is the next (or previous if past=true)
63
+ * occurrence of the given weekday, starting from this.#value.
64
+ *
65
+ * @param {number|string} weekday - Weekday index (0=Sunday…6=Saturday)
66
+ * or a localized weekday name.
67
+ * @param {boolean} past - If true → return previous occurrence instead of next.
68
+ * @param {string} [locale] - Optional locale for weekday names.
69
+ */
70
+ setWeekday(weekday: number | string, past?: boolean, locale?: string): bbnDt<any>;
71
+ }
72
+ export default bbnDt;