@bbn/bbn 2.0.63 → 2.0.65
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 +3 -3
- package/dist/dt/classes/date.js +6 -1
- package/dist/dt/classes/dateTime.d.ts +4 -3
- package/dist/dt/classes/dateTime.js +24 -1
- package/dist/dt/classes/monthDay.d.ts +3 -3
- package/dist/dt/classes/monthDay.js +12 -1
- package/dist/dt/classes/time.d.ts +1 -1
- package/dist/dt/classes/time.js +15 -1
- package/dist/dt/classes/yearMonth.d.ts +3 -3
- package/dist/dt/classes/yearMonth.js +12 -1
- package/dist/dt/classes/zoned.d.ts +4 -3
- package/dist/dt/classes/zoned.js +24 -1
- package/dist/dt/functions/parse.d.ts +1 -7
- package/dist/dt/vars/types.d.ts +2 -2
- package/dist/dt.d.ts +1 -2
- package/package.json +1 -1
- package/dist/dt/classes/dt.d.ts +0 -59
- package/dist/dt/classes/dt.js +0 -409
- package/dist/dt/classes/duration.d.ts +0 -39
- package/dist/dt/classes/duration.js +0 -185
- package/dist/dt/functions/getWeekday.d.ts +0 -3
- package/dist/dt/functions/getWeekday.js +0 -58
- package/dist/dt/vars/units.d.ts +0 -11
- package/dist/dt/vars/units.js +0 -109
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
|
-
import
|
|
3
|
-
import { BbnDtKind } from '../vars/types.js';
|
|
2
|
+
import { bbnDtKind } from '../vars/types.js';
|
|
4
3
|
export default class bbnDtDate extends bbnDt<Temporal.PlainDate> {
|
|
5
4
|
#private;
|
|
6
|
-
readonly kind:
|
|
5
|
+
readonly kind: bbnDtKind;
|
|
7
6
|
constructor(y?: any, m?: number, d?: number);
|
|
8
7
|
protected compareSameKind(other: this): -1 | 0 | 1;
|
|
9
8
|
get value(): Temporal.PlainDate;
|
|
9
|
+
fdate(long?: boolean, weekday?: boolean): string;
|
|
10
10
|
}
|
package/dist/dt/classes/date.js
CHANGED
|
@@ -11,7 +11,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
11
11
|
};
|
|
12
12
|
var _bbnDtDate_value;
|
|
13
13
|
import { Temporal } from 'temporal-polyfill';
|
|
14
|
-
import bbnDt from './dt.js';
|
|
15
14
|
class bbnDtDate extends bbnDt {
|
|
16
15
|
constructor(y, m, d) {
|
|
17
16
|
super();
|
|
@@ -43,6 +42,12 @@ class bbnDtDate extends bbnDt {
|
|
|
43
42
|
get value() {
|
|
44
43
|
return __classPrivateFieldGet(this, _bbnDtDate_value, "f");
|
|
45
44
|
}
|
|
45
|
+
fdate(long = false, weekday = false) {
|
|
46
|
+
const date = new Date(this.year(), this.month() - 1, this.day());
|
|
47
|
+
const opt = Object.assign({ year: 'numeric', month: long ? 'long' : 'numeric', day: 'numeric' }, (weekday ? { weekday: (long ? 'long' : 'short') } : {}));
|
|
48
|
+
const d = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
|
|
49
|
+
return d.format(date);
|
|
50
|
+
}
|
|
46
51
|
}
|
|
47
52
|
_bbnDtDate_value = new WeakMap();
|
|
48
53
|
export default bbnDtDate;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
|
-
import {
|
|
3
|
-
import bbnDt from './dt.js';
|
|
2
|
+
import { bbnDtKind } from '../vars/types.js';
|
|
4
3
|
export default class bbnDtDateTime extends bbnDt<Temporal.PlainDateTime> {
|
|
5
4
|
#private;
|
|
6
|
-
readonly kind:
|
|
5
|
+
readonly kind: bbnDtKind;
|
|
7
6
|
constructor(y?: any, m?: number, d?: number, h?: number, i?: number, s?: number, ms?: number);
|
|
8
7
|
get value(): Temporal.PlainDateTime;
|
|
8
|
+
fdate(long?: boolean, withTime?: boolean, weekday?: boolean): string;
|
|
9
|
+
ftime(withSeconds?: boolean): string;
|
|
9
10
|
}
|
|
@@ -11,7 +11,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
11
11
|
};
|
|
12
12
|
var _bbnDtDateTime_value;
|
|
13
13
|
import { Temporal } from 'temporal-polyfill';
|
|
14
|
-
import bbnDt from './dt.js';
|
|
15
14
|
class bbnDtDateTime extends bbnDt {
|
|
16
15
|
constructor(y, m, d, h, i, s, ms) {
|
|
17
16
|
super();
|
|
@@ -42,6 +41,30 @@ class bbnDtDateTime extends bbnDt {
|
|
|
42
41
|
get value() {
|
|
43
42
|
return __classPrivateFieldGet(this, _bbnDtDateTime_value, "f");
|
|
44
43
|
}
|
|
44
|
+
fdate(long = false, withTime = false, weekday = false) {
|
|
45
|
+
if (!this.value) {
|
|
46
|
+
return '';
|
|
47
|
+
}
|
|
48
|
+
const date = new Date(this.year(), this.month() - 1, this.day(), this.hour(), this.minute(), this.second());
|
|
49
|
+
const opt = Object.assign(Object.assign({ year: 'numeric', month: long ? 'long' : 'numeric', day: 'numeric' }, (weekday ? { weekday: (long ? 'long' : 'short') } : {})), (withTime ? { hour: (long ? '2-digit' : 'numeric'), minute: '2-digit' } : {}));
|
|
50
|
+
const d = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
|
|
51
|
+
return d.format(date);
|
|
52
|
+
}
|
|
53
|
+
ftime(withSeconds = false) {
|
|
54
|
+
if (!this.value) {
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
const date = new Date(2000, 1, 1, this.hour(), this.minute(), this.second());
|
|
58
|
+
const opt = {
|
|
59
|
+
hour: '2-digit',
|
|
60
|
+
minute: '2-digit',
|
|
61
|
+
};
|
|
62
|
+
if (withSeconds) {
|
|
63
|
+
opt.second = '2-digit';
|
|
64
|
+
}
|
|
65
|
+
const t = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
|
|
66
|
+
return t.format(date);
|
|
67
|
+
}
|
|
45
68
|
}
|
|
46
69
|
_bbnDtDateTime_value = new WeakMap();
|
|
47
70
|
export default bbnDtDateTime;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
|
-
import {
|
|
3
|
-
import bbnDt from './dt.js';
|
|
2
|
+
import { bbnDtKind } from '../vars/types.js';
|
|
4
3
|
export default class bbnDtMonthDay extends bbnDt<Temporal.PlainMonthDay> {
|
|
5
4
|
#private;
|
|
6
|
-
readonly kind:
|
|
5
|
+
readonly kind: bbnDtKind;
|
|
7
6
|
constructor(m?: any, d?: number);
|
|
8
7
|
get value(): Temporal.PlainMonthDay;
|
|
8
|
+
fdate(long?: boolean, withTime?: boolean, weekday?: boolean): string;
|
|
9
9
|
}
|
|
@@ -11,7 +11,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
11
11
|
};
|
|
12
12
|
var _bbnDtMonthDay_value;
|
|
13
13
|
import { Temporal } from 'temporal-polyfill';
|
|
14
|
-
import bbnDt from './dt.js';
|
|
15
14
|
class bbnDtMonthDay extends bbnDt {
|
|
16
15
|
constructor(m, d) {
|
|
17
16
|
super();
|
|
@@ -43,6 +42,18 @@ class bbnDtMonthDay extends bbnDt {
|
|
|
43
42
|
get value() {
|
|
44
43
|
return __classPrivateFieldGet(this, _bbnDtMonthDay_value, "f");
|
|
45
44
|
}
|
|
45
|
+
fdate(long = false, withTime = false, weekday = false) {
|
|
46
|
+
if (!this.value) {
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
const date = new Date(2000, this.month() - 1, this.day());
|
|
50
|
+
const opt = {
|
|
51
|
+
month: long ? 'long' : 'numeric',
|
|
52
|
+
day: 'numeric'
|
|
53
|
+
};
|
|
54
|
+
const d = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
|
|
55
|
+
return d.format(date);
|
|
56
|
+
}
|
|
46
57
|
}
|
|
47
58
|
_bbnDtMonthDay_value = new WeakMap();
|
|
48
59
|
export default bbnDtMonthDay;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
|
-
import bbnDt from './dt.js';
|
|
3
2
|
export default class bbnDtTime extends bbnDt<Temporal.PlainTime> {
|
|
4
3
|
#private;
|
|
5
4
|
readonly kind: 'time';
|
|
6
5
|
constructor(h?: any, i?: number, s?: number, ms?: number);
|
|
7
6
|
get value(): Temporal.PlainTime;
|
|
7
|
+
ftime(withSeconds?: boolean): string;
|
|
8
8
|
}
|
package/dist/dt/classes/time.js
CHANGED
|
@@ -11,7 +11,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
11
11
|
};
|
|
12
12
|
var _bbnDtTime_value;
|
|
13
13
|
import { Temporal } from 'temporal-polyfill';
|
|
14
|
-
import bbnDt from './dt.js';
|
|
15
14
|
class bbnDtTime extends bbnDt {
|
|
16
15
|
constructor(h, i, s, ms) {
|
|
17
16
|
super();
|
|
@@ -45,6 +44,21 @@ class bbnDtTime extends bbnDt {
|
|
|
45
44
|
get value() {
|
|
46
45
|
return __classPrivateFieldGet(this, _bbnDtTime_value, "f");
|
|
47
46
|
}
|
|
47
|
+
ftime(withSeconds = false) {
|
|
48
|
+
if (!this.value) {
|
|
49
|
+
return '';
|
|
50
|
+
}
|
|
51
|
+
const date = new Date(2000, 1, 1, this.hour(), this.minute(), this.second());
|
|
52
|
+
const opt = {
|
|
53
|
+
hour: '2-digit',
|
|
54
|
+
minute: '2-digit',
|
|
55
|
+
};
|
|
56
|
+
if (withSeconds) {
|
|
57
|
+
opt.second = '2-digit';
|
|
58
|
+
}
|
|
59
|
+
const t = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
|
|
60
|
+
return t.format(date);
|
|
61
|
+
}
|
|
48
62
|
}
|
|
49
63
|
_bbnDtTime_value = new WeakMap();
|
|
50
64
|
export default bbnDtTime;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
|
-
import {
|
|
3
|
-
import { bbnDt } from './dt.js';
|
|
2
|
+
import { bbnDtKind } from '../vars/types.js';
|
|
4
3
|
export default class bbnDtYearMonth extends bbnDt<Temporal.PlainYearMonth> {
|
|
5
4
|
#private;
|
|
6
|
-
readonly kind:
|
|
5
|
+
readonly kind: bbnDtKind;
|
|
7
6
|
constructor(y?: any, m?: number);
|
|
8
7
|
get value(): Temporal.PlainYearMonth;
|
|
8
|
+
fdate(long?: boolean, withTime?: boolean, weekday?: boolean): string;
|
|
9
9
|
}
|
|
@@ -11,7 +11,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
11
11
|
};
|
|
12
12
|
var _bbnDtYearMonth_value;
|
|
13
13
|
import { Temporal } from 'temporal-polyfill';
|
|
14
|
-
import { bbnDt } from './dt.js';
|
|
15
14
|
class bbnDtYearMonth extends bbnDt {
|
|
16
15
|
constructor(y, m) {
|
|
17
16
|
super();
|
|
@@ -40,6 +39,18 @@ class bbnDtYearMonth extends bbnDt {
|
|
|
40
39
|
get value() {
|
|
41
40
|
return __classPrivateFieldGet(this, _bbnDtYearMonth_value, "f");
|
|
42
41
|
}
|
|
42
|
+
fdate(long = false, withTime = false, weekday = false) {
|
|
43
|
+
if (!this.value) {
|
|
44
|
+
return '';
|
|
45
|
+
}
|
|
46
|
+
const date = new Date(this.year(), this.month() - 1);
|
|
47
|
+
const opt = {
|
|
48
|
+
year: 'numeric',
|
|
49
|
+
month: long ? 'long' : 'numeric',
|
|
50
|
+
};
|
|
51
|
+
const d = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
|
|
52
|
+
return d.format(date);
|
|
53
|
+
}
|
|
43
54
|
}
|
|
44
55
|
_bbnDtYearMonth_value = new WeakMap();
|
|
45
56
|
export default bbnDtYearMonth;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
|
-
import {
|
|
3
|
-
import bbnDt from './dt.js';
|
|
2
|
+
import { bbnDtKind } from '../vars/types.js';
|
|
4
3
|
export default class bbnDtZoned extends bbnDt<Temporal.ZonedDateTime> {
|
|
5
4
|
#private;
|
|
6
|
-
readonly kind:
|
|
5
|
+
readonly kind: bbnDtKind;
|
|
7
6
|
constructor(z?: any, y?: any, m?: number, d?: number, h?: number, i?: number, s?: number, ms?: number);
|
|
8
7
|
get value(): Temporal.ZonedDateTime;
|
|
8
|
+
fdate(long?: boolean, withTime?: boolean, weekday?: boolean): string;
|
|
9
|
+
ftime(withSeconds?: boolean): string;
|
|
9
10
|
}
|
package/dist/dt/classes/zoned.js
CHANGED
|
@@ -12,7 +12,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
12
12
|
var _bbnDtZoned_value;
|
|
13
13
|
import { Temporal } from 'temporal-polyfill';
|
|
14
14
|
import fromJsDate from '../functions/fromJsDate.js';
|
|
15
|
-
import bbnDt from './dt.js';
|
|
16
15
|
class bbnDtZoned extends bbnDt {
|
|
17
16
|
constructor(z, y, m, d, h, i, s, ms) {
|
|
18
17
|
super();
|
|
@@ -45,6 +44,30 @@ class bbnDtZoned extends bbnDt {
|
|
|
45
44
|
get value() {
|
|
46
45
|
return __classPrivateFieldGet(this, _bbnDtZoned_value, "f");
|
|
47
46
|
}
|
|
47
|
+
fdate(long = false, withTime = false, weekday = false) {
|
|
48
|
+
if (!this.value) {
|
|
49
|
+
return '';
|
|
50
|
+
}
|
|
51
|
+
const date = new Date(this.year(), this.month() - 1, this.day(), this.hour(), this.minute(), this.second());
|
|
52
|
+
const opt = Object.assign(Object.assign({ year: 'numeric', month: long ? 'long' : 'numeric', day: 'numeric' }, (weekday ? { weekday: (long ? 'long' : 'short') } : {})), (withTime ? { hour: (long ? '2-digit' : 'numeric'), minute: '2-digit' } : {}));
|
|
53
|
+
const d = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
|
|
54
|
+
return d.format(date);
|
|
55
|
+
}
|
|
56
|
+
ftime(withSeconds = false) {
|
|
57
|
+
if (!this.value) {
|
|
58
|
+
return '';
|
|
59
|
+
}
|
|
60
|
+
const date = new Date(2000, 1, 1, this.hour(), this.minute(), this.second());
|
|
61
|
+
const opt = {
|
|
62
|
+
hour: '2-digit',
|
|
63
|
+
minute: '2-digit',
|
|
64
|
+
};
|
|
65
|
+
if (withSeconds) {
|
|
66
|
+
opt.second = '2-digit';
|
|
67
|
+
}
|
|
68
|
+
const t = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
|
|
69
|
+
return t.format(date);
|
|
70
|
+
}
|
|
48
71
|
}
|
|
49
72
|
_bbnDtZoned_value = new WeakMap();
|
|
50
73
|
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
|
-
}):
|
|
6
|
+
}): bbnDt<any>;
|
package/dist/dt/vars/types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
|
-
export type
|
|
3
|
-
export type
|
|
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;
|
package/dist/dt.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import bbnDtDateTime from './dt/classes/dateTime.js';
|
|
2
1
|
import parse from './dt/functions/parse.js';
|
|
3
2
|
import guessFormat from './dt/functions/guessFormat.js';
|
|
4
3
|
declare const dt: {
|
|
5
|
-
(value: any, inputFormat?: null | String, cls?: "auto" | "zoned" | "dateTime" | "date" | "time" | "yearMonth" | "monthDay"):
|
|
4
|
+
(value: any, inputFormat?: null | String, cls?: "auto" | "zoned" | "dateTime" | "date" | "time" | "yearMonth" | "monthDay"): bbnDt<any>;
|
|
6
5
|
locales: any;
|
|
7
6
|
parse: typeof parse;
|
|
8
7
|
guessFormat: typeof guessFormat;
|
package/package.json
CHANGED
package/dist/dt/classes/dt.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { BbnDtKind, BbnDtTemporal } from '../vars/types.js';
|
|
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;
|
|
6
|
-
static compare(a: any, b: any, unit: string | undefined): -1 | 0 | 1;
|
|
7
|
-
compare(other: any, unit?: string): -1 | 0 | 1;
|
|
8
|
-
add(amount: number | bbnDtDuration | object, unit?: string): TValue;
|
|
9
|
-
subtract(amount: number | bbnDtDuration | object, unit?: string): TValue;
|
|
10
|
-
isBefore(other: bbnDt<any>): boolean;
|
|
11
|
-
isAfter(other: bbnDt<any>): boolean;
|
|
12
|
-
isSame(other: bbnDt<any>): boolean;
|
|
13
|
-
equals(other: bbnDt<any>): boolean;
|
|
14
|
-
toJSON(): {
|
|
15
|
-
kind: BbnDtKind;
|
|
16
|
-
value: string;
|
|
17
|
-
};
|
|
18
|
-
toString(): string;
|
|
19
|
-
year(v?: any): number | TValue;
|
|
20
|
-
month(v?: any): number | TValue;
|
|
21
|
-
day(v?: any): number | TValue;
|
|
22
|
-
hour(v?: any): number | TValue;
|
|
23
|
-
minute(v?: any): number | TValue;
|
|
24
|
-
second(v?: any): number | TValue;
|
|
25
|
-
weekday(): number;
|
|
26
|
-
get YYYY(): string;
|
|
27
|
-
get YY(): string;
|
|
28
|
-
get MMMM(): string;
|
|
29
|
-
get MMM(): string;
|
|
30
|
-
get MM(): string;
|
|
31
|
-
get M(): string;
|
|
32
|
-
get EE(): string;
|
|
33
|
-
get DD(): string;
|
|
34
|
-
get d(): string;
|
|
35
|
-
get dddd(): string;
|
|
36
|
-
get ddd(): string;
|
|
37
|
-
get D(): string;
|
|
38
|
-
get HH(): string;
|
|
39
|
-
get H(): string;
|
|
40
|
-
get II(): string;
|
|
41
|
-
get mm(): string;
|
|
42
|
-
get I(): string;
|
|
43
|
-
get SS(): string;
|
|
44
|
-
get S(): string;
|
|
45
|
-
get WW(): string;
|
|
46
|
-
get W(): string;
|
|
47
|
-
format(format?: string): string;
|
|
48
|
-
/**
|
|
49
|
-
* Returns a NEW date that is the next (or previous if past=true)
|
|
50
|
-
* occurrence of the given weekday, starting from this.#value.
|
|
51
|
-
*
|
|
52
|
-
* @param {number|string} weekday - Weekday index (0=Sunday…6=Saturday)
|
|
53
|
-
* or a localized weekday name.
|
|
54
|
-
* @param {boolean} past - If true → return previous occurrence instead of next.
|
|
55
|
-
* @param {string} [locale] - Optional locale for weekday names.
|
|
56
|
-
*/
|
|
57
|
-
setWeekday(weekday: number | string, past?: boolean, locale?: string): TValue;
|
|
58
|
-
}
|
|
59
|
-
export default bbnDt;
|