@bbn/bbn 2.0.103 → 2.0.105
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/classes/date.d.ts +1 -0
- package/dist/dt/classes/date.js +12 -0
- package/dist/dt/classes/dateTime.d.ts +1 -0
- package/dist/dt/classes/dateTime.js +12 -0
- package/dist/dt/classes/dt.d.ts +1 -0
- package/dist/dt/classes/dt.js +1 -0
- package/dist/dt/classes/yearMonth.d.ts +1 -0
- package/dist/dt/classes/yearMonth.js +16 -0
- package/dist/dt.js +1 -1
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ export default class bbnDtDate extends bbnDt<Temporal.PlainDate> {
|
|
|
4
4
|
readonly kind: bbnDtKind;
|
|
5
5
|
constructor(y?: any, m?: number, d?: number);
|
|
6
6
|
protected compareSameKind(other: this): -1 | 0 | 1;
|
|
7
|
+
format(format?: string | boolean): string;
|
|
7
8
|
ftime(withSeconds?: boolean): string;
|
|
8
9
|
fdate(long?: boolean, weekday?: boolean): string;
|
|
9
10
|
}
|
package/dist/dt/classes/date.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
2
|
import bbnDt from './dt.js';
|
|
3
|
+
import getRow from '../../fn/object/getRow.js';
|
|
3
4
|
export default class bbnDtDate extends bbnDt {
|
|
4
5
|
constructor(y, m, d) {
|
|
5
6
|
let value;
|
|
@@ -31,6 +32,17 @@ export default class bbnDtDate extends bbnDt {
|
|
|
31
32
|
const cmp = Temporal.PlainDate.compare(this.value, other.value);
|
|
32
33
|
return (cmp < 0 ? -1 : cmp > 0 ? 1 : 0);
|
|
33
34
|
}
|
|
35
|
+
format(format) {
|
|
36
|
+
// long
|
|
37
|
+
if (format === true) {
|
|
38
|
+
format = getRow(bbn.dt.locales.date, { year: 'numeric', month: 'long', day: 'long', weekday: 'long' }).pattern;
|
|
39
|
+
}
|
|
40
|
+
// short
|
|
41
|
+
if (!format) {
|
|
42
|
+
format = getRow(bbn.dt.locales.date, { year: 'numeric', month: 'numeric', day: 'numeric' }).pattern;
|
|
43
|
+
}
|
|
44
|
+
return bbnDt.constructor.prototype.formatDate.call(this, this.value, format);
|
|
45
|
+
}
|
|
34
46
|
ftime(withSeconds = false) {
|
|
35
47
|
return '00:00' + (withSeconds ? ':00' : '');
|
|
36
48
|
}
|
|
@@ -3,6 +3,7 @@ import bbnDt from './dt.js';
|
|
|
3
3
|
export default class bbnDtDateTime extends bbnDt<Temporal.PlainDateTime> {
|
|
4
4
|
readonly kind: bbnDtKind;
|
|
5
5
|
constructor(y?: any, m?: number, d?: number, h?: number, i?: number, s?: number, ms?: number);
|
|
6
|
+
format(format?: string | boolean): string;
|
|
6
7
|
fdate(long?: boolean, withTime?: boolean, weekday?: boolean): string;
|
|
7
8
|
ftime(withSeconds?: boolean): string;
|
|
8
9
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
2
|
import bbnDt from './dt.js';
|
|
3
|
+
import getRow from '../../fn/object/getRow.js';
|
|
3
4
|
export default class bbnDtDateTime extends bbnDt {
|
|
4
5
|
constructor(y, m, d, h, i, s, ms) {
|
|
5
6
|
let value;
|
|
@@ -27,6 +28,17 @@ export default class bbnDtDateTime extends bbnDt {
|
|
|
27
28
|
super(value);
|
|
28
29
|
this.kind = 'datetime';
|
|
29
30
|
}
|
|
31
|
+
format(format) {
|
|
32
|
+
// long
|
|
33
|
+
if (format === true) {
|
|
34
|
+
format = getRow(bbn.dt.locales.date, { year: 'numeric', month: 'long', day: 'long', weekday: 'long', hour: '2-digit', minute: '2-digit', second: undefined }).pattern;
|
|
35
|
+
}
|
|
36
|
+
// short
|
|
37
|
+
if (!format) {
|
|
38
|
+
format = getRow(bbn.dt.locales.date, { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: '2-digit', second: undefined }).pattern;
|
|
39
|
+
}
|
|
40
|
+
return bbnDt.constructor.prototype.formatDate.call(this, this.value, format);
|
|
41
|
+
}
|
|
30
42
|
fdate(long = false, withTime = false, weekday = false) {
|
|
31
43
|
if (!this.value) {
|
|
32
44
|
return '';
|
package/dist/dt/classes/dt.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare abstract class bbnDt<TValue extends bbnDtTemporal> {
|
|
|
5
5
|
#private;
|
|
6
6
|
abstract readonly kind: bbnDtKind;
|
|
7
7
|
readonly __bbnNoData = true;
|
|
8
|
+
readonly __isBbnDt = true;
|
|
8
9
|
constructor(value?: TValue);
|
|
9
10
|
get value(): TValue | undefined;
|
|
10
11
|
get hasFullDate(): boolean;
|
package/dist/dt/classes/dt.js
CHANGED
|
@@ -22,6 +22,7 @@ import camelToCss from '../../fn/string/camelToCss.js';
|
|
|
22
22
|
export class bbnDt {
|
|
23
23
|
constructor(value) {
|
|
24
24
|
this.__bbnNoData = true;
|
|
25
|
+
this.__isBbnDt = true;
|
|
25
26
|
_bbnDt_value.set(this, void 0);
|
|
26
27
|
this.getWeekdayIndex = (name, locale) => {
|
|
27
28
|
const loc = locale || bbn.env.lang;
|
|
@@ -3,5 +3,6 @@ import bbnDt from './dt.js';
|
|
|
3
3
|
export default class bbnDtYearMonth extends bbnDt<Temporal.PlainYearMonth> {
|
|
4
4
|
readonly kind: bbnDtKind;
|
|
5
5
|
constructor(y?: any, m?: number);
|
|
6
|
+
format(format?: string | boolean): string;
|
|
6
7
|
fdate(long?: boolean, withTime?: boolean, weekday?: boolean): string;
|
|
7
8
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
2
|
import bbnDt from './dt.js';
|
|
3
|
+
import getRow from '../../fn/object/getRow.js';
|
|
3
4
|
export default class bbnDtYearMonth extends bbnDt {
|
|
4
5
|
constructor(y, m) {
|
|
5
6
|
let value;
|
|
@@ -28,6 +29,21 @@ export default class bbnDtYearMonth extends bbnDt {
|
|
|
28
29
|
super(value);
|
|
29
30
|
this.kind = 'year-month';
|
|
30
31
|
}
|
|
32
|
+
format(format) {
|
|
33
|
+
// long
|
|
34
|
+
if (format === true) {
|
|
35
|
+
format = getRow(bbn.dt.locales.date, d => (d.year === 'numeric')
|
|
36
|
+
&& (d.month === 'long')
|
|
37
|
+
&& !('day' in d)).pattern;
|
|
38
|
+
}
|
|
39
|
+
// short
|
|
40
|
+
if (!format) {
|
|
41
|
+
format = getRow(bbn.dt.locales.date, d => (d.year === 'numeric')
|
|
42
|
+
&& (d.month === 'numeric')
|
|
43
|
+
&& !('day' in d)).pattern;
|
|
44
|
+
}
|
|
45
|
+
return bbnDt.constructor.prototype.formatDate.call(this, this.value, format);
|
|
46
|
+
}
|
|
31
47
|
fdate(long = false, withTime = false, weekday = false) {
|
|
32
48
|
if (!this.value) {
|
|
33
49
|
return '';
|
package/dist/dt.js
CHANGED
|
@@ -197,7 +197,7 @@ const dt = (value, inputFormat = null, cls = 'auto') => {
|
|
|
197
197
|
if (typeof value === 'number') {
|
|
198
198
|
return new bbnDtDateTime(value);
|
|
199
199
|
}
|
|
200
|
-
else if (value
|
|
200
|
+
else if (value.__isBbnDt) {
|
|
201
201
|
return value;
|
|
202
202
|
}
|
|
203
203
|
else if (value instanceof Date) {
|