@bbn/bbn 2.0.63 → 2.0.64
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 +6 -0
- package/dist/dt/classes/dateTime.d.ts +2 -0
- package/dist/dt/classes/dateTime.js +24 -0
- package/dist/dt/classes/dt.d.ts +12 -1
- package/dist/dt/classes/dt.js +42 -1
- package/dist/dt/classes/monthDay.d.ts +1 -0
- package/dist/dt/classes/monthDay.js +12 -0
- package/dist/dt/classes/time.d.ts +1 -0
- package/dist/dt/classes/time.js +15 -0
- package/dist/dt/classes/yearMonth.d.ts +1 -0
- package/dist/dt/classes/yearMonth.js +12 -0
- package/dist/dt/classes/zoned.d.ts +2 -0
- package/dist/dt/classes/zoned.js +24 -0
- package/dist/dt.d.ts +1 -1
- package/package.json +1 -1
package/dist/dt/classes/date.js
CHANGED
|
@@ -43,6 +43,12 @@ class bbnDtDate extends bbnDt {
|
|
|
43
43
|
get value() {
|
|
44
44
|
return __classPrivateFieldGet(this, _bbnDtDate_value, "f");
|
|
45
45
|
}
|
|
46
|
+
fdate(long = false, weekday = false) {
|
|
47
|
+
const date = new Date(this.year(), this.month() - 1, this.day());
|
|
48
|
+
const opt = Object.assign({ year: 'numeric', month: long ? 'long' : 'numeric', day: 'numeric' }, (weekday ? { weekday: (long ? 'long' : 'short') } : {}));
|
|
49
|
+
const d = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
|
|
50
|
+
return d.format(date);
|
|
51
|
+
}
|
|
46
52
|
}
|
|
47
53
|
_bbnDtDate_value = new WeakMap();
|
|
48
54
|
export default bbnDtDate;
|
|
@@ -6,4 +6,6 @@ export default class bbnDtDateTime extends bbnDt<Temporal.PlainDateTime> {
|
|
|
6
6
|
readonly kind: BbnDtKind;
|
|
7
7
|
constructor(y?: any, m?: number, d?: number, h?: number, i?: number, s?: number, ms?: number);
|
|
8
8
|
get value(): Temporal.PlainDateTime;
|
|
9
|
+
fdate(long?: boolean, withTime?: boolean, weekday?: boolean): string;
|
|
10
|
+
ftime(withSeconds?: boolean): string;
|
|
9
11
|
}
|
|
@@ -42,6 +42,30 @@ class bbnDtDateTime extends bbnDt {
|
|
|
42
42
|
get value() {
|
|
43
43
|
return __classPrivateFieldGet(this, _bbnDtDateTime_value, "f");
|
|
44
44
|
}
|
|
45
|
+
fdate(long = false, withTime = false, weekday = false) {
|
|
46
|
+
if (!this.value) {
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
const date = new Date(this.year(), this.month() - 1, this.day(), this.hour(), this.minute(), this.second());
|
|
50
|
+
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' } : {}));
|
|
51
|
+
const d = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
|
|
52
|
+
return d.format(date);
|
|
53
|
+
}
|
|
54
|
+
ftime(withSeconds = false) {
|
|
55
|
+
if (!this.value) {
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
58
|
+
const date = new Date(2000, 1, 1, this.hour(), this.minute(), this.second());
|
|
59
|
+
const opt = {
|
|
60
|
+
hour: '2-digit',
|
|
61
|
+
minute: '2-digit',
|
|
62
|
+
};
|
|
63
|
+
if (withSeconds) {
|
|
64
|
+
opt.second = '2-digit';
|
|
65
|
+
}
|
|
66
|
+
const t = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
|
|
67
|
+
return t.format(date);
|
|
68
|
+
}
|
|
45
69
|
}
|
|
46
70
|
_bbnDtDateTime_value = new WeakMap();
|
|
47
71
|
export default bbnDtDateTime;
|
package/dist/dt/classes/dt.d.ts
CHANGED
|
@@ -4,6 +4,13 @@ export declare abstract class bbnDt<TValue extends BbnDtTemporal> {
|
|
|
4
4
|
abstract readonly kind: BbnDtKind;
|
|
5
5
|
abstract get value(): TValue;
|
|
6
6
|
static compare(a: any, b: any, unit: string | undefined): -1 | 0 | 1;
|
|
7
|
+
static parse(input: string, format: string | string[], cls?: 'auto' | 'zoned' | 'dateTime' | 'date' | 'time' | 'yearMonth' | 'monthDay', locale?: {
|
|
8
|
+
monthsLong?: string[];
|
|
9
|
+
monthsShort?: string[];
|
|
10
|
+
weekdaysLong?: string[];
|
|
11
|
+
weekdaysShort?: string[];
|
|
12
|
+
}): bbnDt<any>;
|
|
13
|
+
parse(input: string, format: string): bbnDt<any>;
|
|
7
14
|
compare(other: any, unit?: string): -1 | 0 | 1;
|
|
8
15
|
add(amount: number | bbnDtDuration | object, unit?: string): TValue;
|
|
9
16
|
subtract(amount: number | bbnDtDuration | object, unit?: string): TValue;
|
|
@@ -22,7 +29,11 @@ export declare abstract class bbnDt<TValue extends BbnDtTemporal> {
|
|
|
22
29
|
hour(v?: any): number | TValue;
|
|
23
30
|
minute(v?: any): number | TValue;
|
|
24
31
|
second(v?: any): number | TValue;
|
|
25
|
-
weekday(): number;
|
|
32
|
+
weekday(v?: any, past?: any): number | TValue;
|
|
33
|
+
date(v?: any): string | bbnDt<any>;
|
|
34
|
+
datetime(v?: any): string | bbnDt<any>;
|
|
35
|
+
time(v?: any): string | bbnDt<any>;
|
|
36
|
+
week(): number;
|
|
26
37
|
get YYYY(): string;
|
|
27
38
|
get YY(): string;
|
|
28
39
|
get MMMM(): string;
|
package/dist/dt/classes/dt.js
CHANGED
|
@@ -5,6 +5,8 @@ import { unitsCorrespondence, formatsMap } from '../vars/units.js';
|
|
|
5
5
|
import each from '../../fn/loop/each.js';
|
|
6
6
|
import isPrimitive from '../../fn/type/isPrimitive.js';
|
|
7
7
|
import bbnDtDuration from './duration.js';
|
|
8
|
+
import parse from '../functions/parse.js';
|
|
9
|
+
import camelToCss from '../../fn/string/camelToCss.js';
|
|
8
10
|
export class bbnDt {
|
|
9
11
|
static compare(a, b, unit) {
|
|
10
12
|
if (!a || !b) {
|
|
@@ -29,6 +31,12 @@ export class bbnDt {
|
|
|
29
31
|
const diff = a.until(b, { largestUnit: unit });
|
|
30
32
|
return diff.sign; // -1 / 0 / 1
|
|
31
33
|
}
|
|
34
|
+
static parse(input, format, cls = 'auto', locale) {
|
|
35
|
+
return parse(input, format, cls, locale);
|
|
36
|
+
}
|
|
37
|
+
parse(input, format) {
|
|
38
|
+
return bbnDt.parse(input, format, camelToCss(this.kind));
|
|
39
|
+
}
|
|
32
40
|
compare(other, unit) {
|
|
33
41
|
if (!(other instanceof bbnDt)) {
|
|
34
42
|
other = bbn.dt(other, this.kind);
|
|
@@ -185,15 +193,48 @@ export class bbnDt {
|
|
|
185
193
|
}
|
|
186
194
|
return this.value.second;
|
|
187
195
|
}
|
|
188
|
-
weekday() {
|
|
196
|
+
weekday(v, past) {
|
|
189
197
|
if (!this.value) {
|
|
190
198
|
return undefined;
|
|
191
199
|
}
|
|
192
200
|
if (!('dayOfWeek' in this.value)) {
|
|
193
201
|
throw new Error('weekday() is not supported for this type');
|
|
194
202
|
}
|
|
203
|
+
if ((v !== undefined) && !(v instanceof Event)) {
|
|
204
|
+
return this.setWeekday(v, past);
|
|
205
|
+
}
|
|
195
206
|
return this.value.dayOfWeek;
|
|
196
207
|
}
|
|
208
|
+
date(v) {
|
|
209
|
+
if (!this.value) {
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
if (!('year' in this.value) || !('month' in this.value) || !('day' in this.value)) {
|
|
213
|
+
throw new Error('date() is not supported for this type');
|
|
214
|
+
}
|
|
215
|
+
return this.parse(v, 'Y-m-d');
|
|
216
|
+
}
|
|
217
|
+
datetime(v) {
|
|
218
|
+
if (0 in arguments && (v !== undefined) && !(v instanceof Event)) {
|
|
219
|
+
return this.parse(v, 'Y-m-d H:i:s');
|
|
220
|
+
}
|
|
221
|
+
return this.format('Y-m-d H:i:s');
|
|
222
|
+
}
|
|
223
|
+
time(v) {
|
|
224
|
+
if (0 in arguments && (v !== undefined) && !(v instanceof Event)) {
|
|
225
|
+
return this.parse(v, 'H:i:s');
|
|
226
|
+
}
|
|
227
|
+
return this.format('H:i:s');
|
|
228
|
+
}
|
|
229
|
+
week() {
|
|
230
|
+
if (!this.value) {
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
if (!('weekOfYear' in this.value)) {
|
|
234
|
+
throw new Error('week() is not supported for this type');
|
|
235
|
+
}
|
|
236
|
+
return this.value.weekOfYear;
|
|
237
|
+
}
|
|
197
238
|
get YYYY() {
|
|
198
239
|
if ('year' in this.value) {
|
|
199
240
|
return this.year().toString();
|
|
@@ -43,6 +43,18 @@ class bbnDtMonthDay extends bbnDt {
|
|
|
43
43
|
get value() {
|
|
44
44
|
return __classPrivateFieldGet(this, _bbnDtMonthDay_value, "f");
|
|
45
45
|
}
|
|
46
|
+
fdate(long = false, withTime = false, weekday = false) {
|
|
47
|
+
if (!this.value) {
|
|
48
|
+
return '';
|
|
49
|
+
}
|
|
50
|
+
const date = new Date(2000, this.month() - 1, this.day());
|
|
51
|
+
const opt = {
|
|
52
|
+
month: long ? 'long' : 'numeric',
|
|
53
|
+
day: 'numeric'
|
|
54
|
+
};
|
|
55
|
+
const d = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
|
|
56
|
+
return d.format(date);
|
|
57
|
+
}
|
|
46
58
|
}
|
|
47
59
|
_bbnDtMonthDay_value = new WeakMap();
|
|
48
60
|
export default bbnDtMonthDay;
|
package/dist/dt/classes/time.js
CHANGED
|
@@ -45,6 +45,21 @@ class bbnDtTime extends bbnDt {
|
|
|
45
45
|
get value() {
|
|
46
46
|
return __classPrivateFieldGet(this, _bbnDtTime_value, "f");
|
|
47
47
|
}
|
|
48
|
+
ftime(withSeconds = false) {
|
|
49
|
+
if (!this.value) {
|
|
50
|
+
return '';
|
|
51
|
+
}
|
|
52
|
+
const date = new Date(2000, 1, 1, this.hour(), this.minute(), this.second());
|
|
53
|
+
const opt = {
|
|
54
|
+
hour: '2-digit',
|
|
55
|
+
minute: '2-digit',
|
|
56
|
+
};
|
|
57
|
+
if (withSeconds) {
|
|
58
|
+
opt.second = '2-digit';
|
|
59
|
+
}
|
|
60
|
+
const t = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
|
|
61
|
+
return t.format(date);
|
|
62
|
+
}
|
|
48
63
|
}
|
|
49
64
|
_bbnDtTime_value = new WeakMap();
|
|
50
65
|
export default bbnDtTime;
|
|
@@ -40,6 +40,18 @@ class bbnDtYearMonth extends bbnDt {
|
|
|
40
40
|
get value() {
|
|
41
41
|
return __classPrivateFieldGet(this, _bbnDtYearMonth_value, "f");
|
|
42
42
|
}
|
|
43
|
+
fdate(long = false, withTime = false, weekday = false) {
|
|
44
|
+
if (!this.value) {
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
47
|
+
const date = new Date(this.year(), this.month() - 1);
|
|
48
|
+
const opt = {
|
|
49
|
+
year: 'numeric',
|
|
50
|
+
month: long ? 'long' : 'numeric',
|
|
51
|
+
};
|
|
52
|
+
const d = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
|
|
53
|
+
return d.format(date);
|
|
54
|
+
}
|
|
43
55
|
}
|
|
44
56
|
_bbnDtYearMonth_value = new WeakMap();
|
|
45
57
|
export default bbnDtYearMonth;
|
|
@@ -6,4 +6,6 @@ export default class bbnDtZoned extends bbnDt<Temporal.ZonedDateTime> {
|
|
|
6
6
|
readonly kind: BbnDtKind;
|
|
7
7
|
constructor(z?: any, y?: any, m?: number, d?: number, h?: number, i?: number, s?: number, ms?: number);
|
|
8
8
|
get value(): Temporal.ZonedDateTime;
|
|
9
|
+
fdate(long?: boolean, withTime?: boolean, weekday?: boolean): string;
|
|
10
|
+
ftime(withSeconds?: boolean): string;
|
|
9
11
|
}
|
package/dist/dt/classes/zoned.js
CHANGED
|
@@ -45,6 +45,30 @@ class bbnDtZoned extends bbnDt {
|
|
|
45
45
|
get value() {
|
|
46
46
|
return __classPrivateFieldGet(this, _bbnDtZoned_value, "f");
|
|
47
47
|
}
|
|
48
|
+
fdate(long = false, withTime = false, weekday = false) {
|
|
49
|
+
if (!this.value) {
|
|
50
|
+
return '';
|
|
51
|
+
}
|
|
52
|
+
const date = new Date(this.year(), this.month() - 1, this.day(), this.hour(), this.minute(), this.second());
|
|
53
|
+
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' } : {}));
|
|
54
|
+
const d = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
|
|
55
|
+
return d.format(date);
|
|
56
|
+
}
|
|
57
|
+
ftime(withSeconds = false) {
|
|
58
|
+
if (!this.value) {
|
|
59
|
+
return '';
|
|
60
|
+
}
|
|
61
|
+
const date = new Date(2000, 1, 1, this.hour(), this.minute(), this.second());
|
|
62
|
+
const opt = {
|
|
63
|
+
hour: '2-digit',
|
|
64
|
+
minute: '2-digit',
|
|
65
|
+
};
|
|
66
|
+
if (withSeconds) {
|
|
67
|
+
opt.second = '2-digit';
|
|
68
|
+
}
|
|
69
|
+
const t = new Intl.DateTimeFormat([bbn.env.lang, ...navigator.languages], opt);
|
|
70
|
+
return t.format(date);
|
|
71
|
+
}
|
|
48
72
|
}
|
|
49
73
|
_bbnDtZoned_value = new WeakMap();
|
|
50
74
|
export default bbnDtZoned;
|
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"):
|
|
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;
|
|
6
6
|
locales: any;
|
|
7
7
|
parse: typeof parse;
|
|
8
8
|
guessFormat: typeof guessFormat;
|