@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.
- package/dist/bbn.js +1 -1
- package/dist/bbn.js.map +1 -1
- package/dist/dt/classes/date.d.ts +1 -3
- package/dist/dt/classes/date.js +13 -26
- package/dist/dt/classes/dateTime.d.ts +1 -3
- package/dist/dt/classes/dateTime.js +10 -26
- package/dist/dt/classes/dt.d.ts +72 -0
- package/dist/dt/classes/dt.js +470 -0
- package/dist/dt/classes/duration.d.ts +39 -0
- package/dist/dt/classes/duration.js +185 -0
- package/dist/dt/classes/monthDay.d.ts +1 -3
- package/dist/dt/classes/monthDay.js +10 -26
- package/dist/dt/classes/time.d.ts +1 -2
- package/dist/dt/classes/time.js +13 -26
- package/dist/dt/classes/yearMonth.d.ts +1 -3
- package/dist/dt/classes/yearMonth.js +12 -25
- package/dist/dt/classes/zoned.d.ts +1 -3
- package/dist/dt/classes/zoned.js +10 -26
- package/dist/dt/functions/getWeekday.d.ts +3 -0
- package/dist/dt/functions/getWeekday.js +58 -0
- package/dist/dt/vars/types.d.ts +0 -1
- package/dist/dt/vars/units.d.ts +11 -0
- package/dist/dt/vars/units.js +109 -0
- package/dist/dt.d.ts +2 -1
- package/package.json +1 -1
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
|
-
import
|
|
2
|
+
import bbnDt from './dt.js';
|
|
3
3
|
export default class bbnDtMonthDay extends bbnDt<Temporal.PlainMonthDay> {
|
|
4
|
-
#private;
|
|
5
4
|
readonly kind: bbnDtKind;
|
|
6
5
|
constructor(m?: any, d?: number);
|
|
7
|
-
get value(): Temporal.PlainMonthDay;
|
|
8
6
|
fdate(long?: boolean, withTime?: boolean, weekday?: boolean): string;
|
|
9
7
|
}
|
|
@@ -1,46 +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';
|
|
3
|
+
export default class bbnDtMonthDay extends bbnDt {
|
|
15
4
|
constructor(m, d) {
|
|
16
|
-
|
|
17
|
-
_bbnDtMonthDay_value.set(this, void 0);
|
|
18
|
-
this.kind = 'month-day';
|
|
5
|
+
let value;
|
|
19
6
|
if (!m) {
|
|
20
7
|
const d = new Date();
|
|
21
|
-
|
|
8
|
+
value = new Temporal.PlainMonthDay(d.getMonth() + 1, d.getDate());
|
|
22
9
|
}
|
|
23
10
|
else if (d === undefined) {
|
|
24
11
|
if (m instanceof Temporal.PlainMonthDay) {
|
|
25
|
-
|
|
12
|
+
value = m;
|
|
26
13
|
}
|
|
27
14
|
else if (m instanceof Date) {
|
|
28
|
-
|
|
15
|
+
value = new Temporal.PlainMonthDay(m.getMonth() + 1, m.getDate());
|
|
29
16
|
}
|
|
30
17
|
else if (typeof m === 'number') {
|
|
31
18
|
const d = new Date(m);
|
|
32
|
-
|
|
19
|
+
value = new Temporal.PlainMonthDay(d.getMonth() + 1, d.getDate());
|
|
33
20
|
}
|
|
34
21
|
else {
|
|
35
22
|
throw new Error('Invalid value for bbnDtDateTime');
|
|
36
23
|
}
|
|
37
24
|
}
|
|
38
25
|
else {
|
|
39
|
-
|
|
26
|
+
value = new Temporal.PlainMonthDay(m, d);
|
|
40
27
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return __classPrivateFieldGet(this, _bbnDtMonthDay_value, "f");
|
|
28
|
+
super(value);
|
|
29
|
+
this.kind = 'month-day';
|
|
44
30
|
}
|
|
45
31
|
fdate(long = false, withTime = false, weekday = false) {
|
|
46
32
|
if (!this.value) {
|
|
@@ -55,6 +41,4 @@ class bbnDtMonthDay extends bbnDt {
|
|
|
55
41
|
return d.format(date);
|
|
56
42
|
}
|
|
57
43
|
}
|
|
58
|
-
_bbnDtMonthDay_value = new WeakMap();
|
|
59
|
-
export default bbnDtMonthDay;
|
|
60
44
|
;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
|
+
import bbnDt from './dt.js';
|
|
2
3
|
export default class bbnDtTime extends bbnDt<Temporal.PlainTime> {
|
|
3
|
-
#private;
|
|
4
4
|
readonly kind: 'time';
|
|
5
5
|
constructor(h?: any, i?: number, s?: number, ms?: number);
|
|
6
|
-
get value(): Temporal.PlainTime;
|
|
7
6
|
ftime(withSeconds?: boolean): string;
|
|
8
7
|
}
|
package/dist/dt/classes/time.js
CHANGED
|
@@ -1,48 +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';
|
|
3
|
+
export default class bbnDtTime extends bbnDt {
|
|
15
4
|
constructor(h, i, s, ms) {
|
|
16
|
-
|
|
17
|
-
_bbnDtTime_value.set(this, void 0);
|
|
18
|
-
this.kind = 'time';
|
|
5
|
+
let value;
|
|
19
6
|
if (!h) {
|
|
20
7
|
const d = new Date();
|
|
21
|
-
|
|
8
|
+
value = new Temporal.PlainTime(d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds() * 1000000);
|
|
22
9
|
}
|
|
23
10
|
else if (h === undefined) {
|
|
24
11
|
if (h instanceof Temporal.PlainTime) {
|
|
25
|
-
|
|
12
|
+
value = h;
|
|
26
13
|
}
|
|
27
14
|
else if (h instanceof Date) {
|
|
28
|
-
|
|
15
|
+
value = new Temporal.PlainTime(h.getHours(), h.getMinutes(), h.getSeconds(), h.getMilliseconds() * 1000000);
|
|
29
16
|
}
|
|
30
17
|
else if (typeof h === 'number') {
|
|
31
18
|
if (i !== undefined) {
|
|
32
|
-
|
|
19
|
+
value = new Temporal.PlainTime(h, i, s || 0, ms || 0);
|
|
33
20
|
}
|
|
34
21
|
else {
|
|
35
22
|
const d = new Date(h);
|
|
36
|
-
|
|
23
|
+
value = new Temporal.PlainTime(d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds() * 1000000);
|
|
37
24
|
}
|
|
38
25
|
}
|
|
39
26
|
else {
|
|
40
27
|
throw new Error('Invalid value for bbnDtDateTime');
|
|
41
28
|
}
|
|
42
29
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
30
|
+
else {
|
|
31
|
+
value = new Temporal.PlainTime(h, i || 0, s || 0, ms || 0);
|
|
32
|
+
}
|
|
33
|
+
super(value);
|
|
34
|
+
this.kind = 'time';
|
|
46
35
|
}
|
|
47
36
|
ftime(withSeconds = false) {
|
|
48
37
|
if (!this.value) {
|
|
@@ -60,6 +49,4 @@ class bbnDtTime extends bbnDt {
|
|
|
60
49
|
return t.format(date);
|
|
61
50
|
}
|
|
62
51
|
}
|
|
63
|
-
_bbnDtTime_value = new WeakMap();
|
|
64
|
-
export default bbnDtTime;
|
|
65
52
|
;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
|
-
import
|
|
2
|
+
import bbnDt from './dt.js';
|
|
3
3
|
export default class bbnDtYearMonth extends bbnDt<Temporal.PlainYearMonth> {
|
|
4
|
-
#private;
|
|
5
4
|
readonly kind: bbnDtKind;
|
|
6
5
|
constructor(y?: any, m?: number);
|
|
7
|
-
get value(): Temporal.PlainYearMonth;
|
|
8
6
|
fdate(long?: boolean, withTime?: boolean, weekday?: boolean): string;
|
|
9
7
|
}
|
|
@@ -1,43 +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
|
-
|
|
2
|
+
import bbnDt from './dt.js';
|
|
3
|
+
export default class bbnDtYearMonth extends bbnDt {
|
|
15
4
|
constructor(y, m) {
|
|
16
|
-
|
|
17
|
-
_bbnDtYearMonth_value.set(this, void 0);
|
|
18
|
-
this.kind = 'year-month';
|
|
5
|
+
let value;
|
|
19
6
|
if (!y) {
|
|
20
7
|
const d = new Date();
|
|
21
|
-
|
|
8
|
+
value = new Temporal.PlainYearMonth(d.getFullYear(), d.getMonth() + 1);
|
|
22
9
|
}
|
|
23
10
|
else if (m === undefined) {
|
|
24
11
|
if (y instanceof Temporal.PlainYearMonth) {
|
|
25
|
-
|
|
12
|
+
value = y;
|
|
26
13
|
}
|
|
27
14
|
else if (y instanceof Date) {
|
|
28
|
-
|
|
15
|
+
value = new Temporal.PlainYearMonth(y.getFullYear(), y.getMonth() + 1);
|
|
29
16
|
}
|
|
30
17
|
else if (typeof m === 'number') {
|
|
31
18
|
const d = new Date(m);
|
|
32
|
-
|
|
19
|
+
value = new Temporal.PlainYearMonth(d.getFullYear(), d.getMonth() + 1);
|
|
33
20
|
}
|
|
34
21
|
else {
|
|
35
22
|
throw new Error('Invalid value for bbnDtDateTime');
|
|
36
23
|
}
|
|
37
24
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
25
|
+
else {
|
|
26
|
+
value = new Temporal.PlainYearMonth(y, m);
|
|
27
|
+
}
|
|
28
|
+
super(value);
|
|
29
|
+
this.kind = 'year-month';
|
|
41
30
|
}
|
|
42
31
|
fdate(long = false, withTime = false, weekday = false) {
|
|
43
32
|
if (!this.value) {
|
|
@@ -52,6 +41,4 @@ class bbnDtYearMonth extends bbnDt {
|
|
|
52
41
|
return d.format(date);
|
|
53
42
|
}
|
|
54
43
|
}
|
|
55
|
-
_bbnDtYearMonth_value = new WeakMap();
|
|
56
|
-
export default bbnDtYearMonth;
|
|
57
44
|
;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
|
-
import
|
|
2
|
+
import bbnDt from './dt.js';
|
|
3
3
|
export default class bbnDtZoned extends bbnDt<Temporal.ZonedDateTime> {
|
|
4
|
-
#private;
|
|
5
4
|
readonly kind: bbnDtKind;
|
|
6
5
|
constructor(z?: any, y?: any, m?: number, d?: number, h?: number, i?: number, s?: number, ms?: number);
|
|
7
|
-
get value(): Temporal.ZonedDateTime;
|
|
8
6
|
fdate(long?: boolean, withTime?: boolean, weekday?: boolean): string;
|
|
9
7
|
ftime(withSeconds?: boolean): string;
|
|
10
8
|
}
|
package/dist/dt/classes/zoned.js
CHANGED
|
@@ -1,36 +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';
|
|
4
|
+
export default class bbnDtZoned extends bbnDt {
|
|
16
5
|
constructor(z, y, m, d, h, i, s, ms) {
|
|
17
|
-
|
|
18
|
-
_bbnDtZoned_value.set(this, void 0);
|
|
19
|
-
this.kind = 'zoned';
|
|
6
|
+
let value;
|
|
20
7
|
if (!z) {
|
|
21
8
|
const date = new Date();
|
|
22
|
-
|
|
9
|
+
value = new Temporal.ZonedDateTime(BigInt(date.getTime() * 1000000), Intl.DateTimeFormat().resolvedOptions().timeZone);
|
|
23
10
|
}
|
|
24
11
|
else if (y === undefined) {
|
|
25
12
|
if (z instanceof Temporal.ZonedDateTime) {
|
|
26
|
-
|
|
13
|
+
value = z;
|
|
27
14
|
}
|
|
28
15
|
else if (z instanceof Date) {
|
|
29
|
-
|
|
16
|
+
value = fromJsDate(z, true);
|
|
30
17
|
}
|
|
31
18
|
else if (typeof z === 'number') {
|
|
32
19
|
const d = new Date(z);
|
|
33
|
-
|
|
20
|
+
value = fromJsDate(d, true);
|
|
34
21
|
}
|
|
35
22
|
else {
|
|
36
23
|
throw new Error('Invalid value for bbnDtZoned');
|
|
@@ -38,11 +25,10 @@ class bbnDtZoned extends bbnDt {
|
|
|
38
25
|
}
|
|
39
26
|
else {
|
|
40
27
|
const dt = new Temporal.PlainDateTime(y, m, d || 1, h || 0, i || 0, s || 0, ms || 0);
|
|
41
|
-
|
|
28
|
+
value = dt.toZonedDateTime(z || Temporal.Now.timeZoneId());
|
|
42
29
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return __classPrivateFieldGet(this, _bbnDtZoned_value, "f");
|
|
30
|
+
super(value);
|
|
31
|
+
this.kind = 'zoned';
|
|
46
32
|
}
|
|
47
33
|
fdate(long = false, withTime = false, weekday = false) {
|
|
48
34
|
if (!this.value) {
|
|
@@ -69,5 +55,3 @@ class bbnDtZoned extends bbnDt {
|
|
|
69
55
|
return t.format(date);
|
|
70
56
|
}
|
|
71
57
|
}
|
|
72
|
-
_bbnDtZoned_value = new WeakMap();
|
|
73
|
-
export default bbnDtZoned;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const getWeekday = (n, mode = 'long', locale) => {
|
|
2
|
+
if (!mode) {
|
|
3
|
+
const letter = getWeekday(n, 'narrow', locale);
|
|
4
|
+
const abbr = getWeekday(n, 'short', locale);
|
|
5
|
+
const full = getWeekday(n, 'long', locale);
|
|
6
|
+
return {
|
|
7
|
+
letter,
|
|
8
|
+
abbr,
|
|
9
|
+
full,
|
|
10
|
+
long: full,
|
|
11
|
+
short: abbr,
|
|
12
|
+
narrow: letter
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
let m;
|
|
16
|
+
if (mode === 'letter') {
|
|
17
|
+
m = 'narrow';
|
|
18
|
+
}
|
|
19
|
+
else if (mode === 'abbr') {
|
|
20
|
+
m = 'short';
|
|
21
|
+
}
|
|
22
|
+
else if (mode === 'full') {
|
|
23
|
+
m = 'long';
|
|
24
|
+
}
|
|
25
|
+
else if (!['long', 'short', 'narrow'].includes(mode)) {
|
|
26
|
+
throw new Error('Invalid mode for getWeekDay: ' + mode + '. Allowed values are "long", "short", "narrow", "letter", "abbr", "full".');
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
m = mode;
|
|
30
|
+
}
|
|
31
|
+
// Create a date with the right weekday
|
|
32
|
+
// 2023-01-01 was a Sunday → base for offset
|
|
33
|
+
const base = new Date(2023, 0, 1 + n);
|
|
34
|
+
return base.toLocaleDateString([locale || bbn.env.lang, ...navigator.languages], { weekday: m });
|
|
35
|
+
};
|
|
36
|
+
const getWeekdayIndex = (name, locale) => {
|
|
37
|
+
const loc = locale || bbn.env.lang;
|
|
38
|
+
const input = name.trim().toLowerCase();
|
|
39
|
+
// Build a localized map only once per locale (optional optimization)
|
|
40
|
+
const langs = [loc, ...navigator.languages];
|
|
41
|
+
for (let i = 0; i < langs.length; i++) {
|
|
42
|
+
if (!langs[i]) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const formatter = new Intl.DateTimeFormat(langs[i], { weekday: "long" });
|
|
46
|
+
// Generate localized weekday names for Sun → Sat
|
|
47
|
+
for (let i = 0; i < 7; i++) {
|
|
48
|
+
// 2023-01-01 was Sunday
|
|
49
|
+
const date = new Date(2023, 0, 1 + i);
|
|
50
|
+
const localized = formatter.format(date).toLowerCase();
|
|
51
|
+
if (localized === input) {
|
|
52
|
+
return i; // JS weekday number
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
throw new Error(`Unknown weekday name '${name}' for locale '${loc}'`);
|
|
57
|
+
};
|
|
58
|
+
export { getWeekday, getWeekdayIndex };
|
package/dist/dt/vars/types.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
|
-
export type bbnDtKind = 'datetime' | 'date' | 'time' | 'year-month' | 'month-day' | 'zoned';
|
|
3
2
|
export type bbnDtTemporal = Temporal.PlainDateTime | Temporal.PlainDate | Temporal.PlainTime | Temporal.PlainYearMonth | Temporal.PlainMonthDay | Temporal.ZonedDateTime;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const units: [string, Intl.RelativeTimeFormatUnit, number][];
|
|
2
|
+
declare const unitsCorrespondence: {
|
|
3
|
+
[key: string]: string;
|
|
4
|
+
};
|
|
5
|
+
declare const unitsMap: {
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
};
|
|
8
|
+
declare const formatsMap: {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
};
|
|
11
|
+
export { units, unitsCorrespondence, unitsMap, formatsMap };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
const units = [
|
|
2
|
+
['y', "year", 365 * 24 * 60 * 60 * 1000],
|
|
3
|
+
['m', "month", 30 * 24 * 60 * 60 * 1000],
|
|
4
|
+
['w', "week", 7 * 24 * 60 * 60 * 1000],
|
|
5
|
+
['d', "day", 24 * 60 * 60 * 1000],
|
|
6
|
+
['h', "hour", 60 * 60 * 1000],
|
|
7
|
+
['i', "minute", 60 * 1000],
|
|
8
|
+
['s', "second", 1000]
|
|
9
|
+
];
|
|
10
|
+
const unitsCorrespondence = {
|
|
11
|
+
'years': 'y',
|
|
12
|
+
'year': 'y',
|
|
13
|
+
'YEARS': 'y',
|
|
14
|
+
'YEAR': 'y',
|
|
15
|
+
'Years': 'y',
|
|
16
|
+
'Year': 'y',
|
|
17
|
+
'YYYY': 'y',
|
|
18
|
+
'YY': 'y',
|
|
19
|
+
'yyyy': 'y',
|
|
20
|
+
'yy': 'y',
|
|
21
|
+
'months': 'm',
|
|
22
|
+
'month': 'm',
|
|
23
|
+
'Months': 'm',
|
|
24
|
+
'Month': 'm',
|
|
25
|
+
'MONTHS': 'm',
|
|
26
|
+
'MONTH': 'm',
|
|
27
|
+
'MMMM': 'm',
|
|
28
|
+
'MMM': 'm',
|
|
29
|
+
'MM': 'm',
|
|
30
|
+
'weekday': 'e',
|
|
31
|
+
'WEEKDAY': 'e',
|
|
32
|
+
'ee': 'e',
|
|
33
|
+
'EE': 'e',
|
|
34
|
+
'ddd': 'e',
|
|
35
|
+
'days': 'd',
|
|
36
|
+
'day': 'd',
|
|
37
|
+
'Days': 'd',
|
|
38
|
+
'Day': 'd',
|
|
39
|
+
'DAYS': 'd',
|
|
40
|
+
'DAY': 'd',
|
|
41
|
+
'DD': 'd',
|
|
42
|
+
'dd': 'd',
|
|
43
|
+
'hours': 'h',
|
|
44
|
+
'hour': 'h',
|
|
45
|
+
'Hours': 'h',
|
|
46
|
+
'Hour': 'h',
|
|
47
|
+
'HOURS': 'h',
|
|
48
|
+
'HOUR': 'h',
|
|
49
|
+
'HH': 'h',
|
|
50
|
+
'hr': 'h',
|
|
51
|
+
'hh': 'h',
|
|
52
|
+
'minutes': 'i',
|
|
53
|
+
'minute': 'i',
|
|
54
|
+
'Minutes': 'i',
|
|
55
|
+
'Minute': 'i',
|
|
56
|
+
'MINUTES': 'i',
|
|
57
|
+
'MINUTE': 'i',
|
|
58
|
+
'II': 'i',
|
|
59
|
+
'ii': 'i',
|
|
60
|
+
'mn': 'i',
|
|
61
|
+
'mm': 'i',
|
|
62
|
+
'min': 'i',
|
|
63
|
+
'SS': 's',
|
|
64
|
+
'ss': 's',
|
|
65
|
+
'seconds': 's',
|
|
66
|
+
'second': 's',
|
|
67
|
+
'Seconds': 's',
|
|
68
|
+
'Second': 's',
|
|
69
|
+
'SECONDS': 's',
|
|
70
|
+
'SECOND': 's',
|
|
71
|
+
'sec': 's',
|
|
72
|
+
'WW': 'w',
|
|
73
|
+
'Y': 'y',
|
|
74
|
+
'y': 'y',
|
|
75
|
+
'M': 'm',
|
|
76
|
+
'm': 'm',
|
|
77
|
+
'e': 'e',
|
|
78
|
+
'E': 'e',
|
|
79
|
+
'D': 'd',
|
|
80
|
+
'd': 'd',
|
|
81
|
+
'H': 'h',
|
|
82
|
+
'h': 'h',
|
|
83
|
+
'n': 'i',
|
|
84
|
+
'i': 'i',
|
|
85
|
+
's': 's',
|
|
86
|
+
'S': 's',
|
|
87
|
+
'W': 'w',
|
|
88
|
+
'w': 'w'
|
|
89
|
+
};
|
|
90
|
+
const unitsMap = {
|
|
91
|
+
'y': 'Year',
|
|
92
|
+
'm': 'Month',
|
|
93
|
+
'd': 'Date',
|
|
94
|
+
'w': 'Week',
|
|
95
|
+
'h': 'Hours',
|
|
96
|
+
'i': 'Minutes',
|
|
97
|
+
's': 'Seconds'
|
|
98
|
+
};
|
|
99
|
+
const formatsMap = {
|
|
100
|
+
'y': 'YYYY',
|
|
101
|
+
'm': 'MM',
|
|
102
|
+
'd': 'DD',
|
|
103
|
+
'e': 'EE',
|
|
104
|
+
'w': 'WW',
|
|
105
|
+
'h': 'HH',
|
|
106
|
+
'i': 'II',
|
|
107
|
+
's': 'SS'
|
|
108
|
+
};
|
|
109
|
+
export { units, unitsCorrespondence, unitsMap, formatsMap };
|
package/dist/dt.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import bbnDtDateTime from './dt/classes/dateTime.js';
|
|
1
2
|
import parse from './dt/functions/parse.js';
|
|
2
3
|
import guessFormat from './dt/functions/guessFormat.js';
|
|
3
4
|
declare const dt: {
|
|
4
|
-
(value: any, inputFormat?: null | String, cls?: "auto" | "zoned" | "dateTime" | "date" | "time" | "yearMonth" | "monthDay"): bbnDt<any
|
|
5
|
+
(value: any, inputFormat?: null | String, cls?: "auto" | "zoned" | "dateTime" | "date" | "time" | "yearMonth" | "monthDay"): bbnDt<any> | bbnDtDateTime;
|
|
5
6
|
locales: any;
|
|
6
7
|
parse: typeof parse;
|
|
7
8
|
guessFormat: typeof guessFormat;
|