@bbn/bbn 2.0.146 → 2.0.148
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/dateTime.js +1 -1
- package/dist/dt/classes/dt.d.ts +1 -1
- package/dist/dt/classes/dt.js +1 -1
- package/dist/dt/functions/parse.js +5 -3
- package/dist/dt.js +1 -1
- package/package.json +4 -3
|
@@ -5,7 +5,7 @@ export default class bbnDtDateTime extends bbnDt {
|
|
|
5
5
|
constructor(y, m, d, h, i, s, ms) {
|
|
6
6
|
let value;
|
|
7
7
|
if (!y) {
|
|
8
|
-
value = Temporal.PlainDateTime.from(Temporal.Now.
|
|
8
|
+
value = Temporal.PlainDateTime.from(Temporal.Now.plainDateTimeISO());
|
|
9
9
|
}
|
|
10
10
|
else if (m === undefined) {
|
|
11
11
|
if (y instanceof Temporal.PlainDateTime) {
|
package/dist/dt/classes/dt.d.ts
CHANGED
|
@@ -108,7 +108,7 @@ export declare abstract class bbnDt<TValue extends bbnDtTemporal> {
|
|
|
108
108
|
setWeekday(weekday: number | string, past?: boolean, locale?: string): bbnDt<any>;
|
|
109
109
|
diff(date: any, unit?: string, abs?: boolean): number;
|
|
110
110
|
guessUnit(valueInMs: number): string | null;
|
|
111
|
-
fromNow(unit?: string):
|
|
111
|
+
fromNow(unit?: string): any;
|
|
112
112
|
fromDate(date: any, unit?: string): string;
|
|
113
113
|
startOf(unit?: string): bbnDt<any>;
|
|
114
114
|
endOf(unit?: string): bbnDt<any>;
|
package/dist/dt/classes/dt.js
CHANGED
|
@@ -684,7 +684,7 @@ export class bbnDt {
|
|
|
684
684
|
return str;
|
|
685
685
|
}
|
|
686
686
|
calendar(short) {
|
|
687
|
-
const now = this.constructor
|
|
687
|
+
const now = new this.constructor();
|
|
688
688
|
const startThis = this.startOf("day");
|
|
689
689
|
const startNow = now.startOf("day");
|
|
690
690
|
const diffDays = startThis.diff(startNow, "day");
|
|
@@ -495,6 +495,7 @@ export default function parse(input, format, cls = 'auto', force, locale) {
|
|
|
495
495
|
let pattern = '';
|
|
496
496
|
const applyFns = [];
|
|
497
497
|
let i = 0;
|
|
498
|
+
let lastPositionMatch = 0;
|
|
498
499
|
while (i < fmt.length) {
|
|
499
500
|
// 1) Handle [literal] blocks first
|
|
500
501
|
if (fmt[i] === '[') {
|
|
@@ -525,6 +526,7 @@ export default function parse(input, format, cls = 'auto', force, locale) {
|
|
|
525
526
|
}
|
|
526
527
|
if (matchedToken) {
|
|
527
528
|
pattern += `(${matchedToken.regex})`;
|
|
529
|
+
lastPositionMatch = pattern.length;
|
|
528
530
|
if (matchedToken.apply) {
|
|
529
531
|
applyFns.push(value => matchedToken.apply(value, ctx));
|
|
530
532
|
}
|
|
@@ -539,7 +541,7 @@ export default function parse(input, format, cls = 'auto', force, locale) {
|
|
|
539
541
|
i += 1;
|
|
540
542
|
}
|
|
541
543
|
}
|
|
542
|
-
const fullRegex = new RegExp('^' + pattern
|
|
544
|
+
const fullRegex = new RegExp('^' + bbn.fn.substr(pattern, 0, lastPositionMatch));
|
|
543
545
|
let match = fullRegex.exec(input);
|
|
544
546
|
if (!match) {
|
|
545
547
|
if (force) {
|
|
@@ -605,8 +607,8 @@ export default function parse(input, format, cls = 'auto', force, locale) {
|
|
|
605
607
|
}
|
|
606
608
|
}
|
|
607
609
|
// ---------- 2) No timezone: decide which Plain* type ----------
|
|
608
|
-
else if (isClsDateTime || (isClsAuto && hasDate && hasTime)) {
|
|
609
|
-
if (!hasFullDate) {
|
|
610
|
+
else if (isClsDateTime || (isClsAuto && (isValid || (hasDate && hasTime)))) {
|
|
611
|
+
if (!hasFullDate && !isValid) {
|
|
610
612
|
throw new Error('PlainDateTime requires year, month and day');
|
|
611
613
|
}
|
|
612
614
|
const d = new T.PlainDateTime(ctx.year, ctx.month, ctx.day, ctx.hour, ctx.minute, ctx.second, ctx.ms * 1000000);
|
package/dist/dt.js
CHANGED
|
@@ -190,7 +190,7 @@ const dt = (value, inputFormat = null, cls = 'auto') => {
|
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
if (typeof value === 'number') {
|
|
193
|
-
return new bbnDtDateTime(value);
|
|
193
|
+
return new bbnDtDateTime(value < 99999999999 ? value * 1000 : value);
|
|
194
194
|
}
|
|
195
195
|
else if (value.__isBbnDt) {
|
|
196
196
|
return value;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bbn/bbn",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.148",
|
|
4
4
|
"description": "Javascript toolkit",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"pub": "npm version patch && npm publish",
|
|
16
16
|
"build": "./node_modules/.bin/rollup -c",
|
|
17
17
|
"all": "npm run type && npm run test && npm run gitauto && npm version patch && npm run build && npm run gitend && npm publish",
|
|
18
|
-
"test": "IS_TESTING=true
|
|
18
|
+
"test": "IS_TESTING=true mocha ./test/type.mjs",
|
|
19
19
|
"wtf": "echo \"Error: no test specified\" && exit 1"
|
|
20
20
|
},
|
|
21
21
|
"keywords": [
|
|
@@ -30,10 +30,11 @@
|
|
|
30
30
|
"@rollup/plugin-replace": "^6.0.3",
|
|
31
31
|
"@rollup/plugin-terser": "^0.4.4",
|
|
32
32
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
33
|
+
"@types/mocha": "^10.0.10",
|
|
33
34
|
"chai": "^6.2.1",
|
|
34
35
|
"jsdom": "27.2.0",
|
|
35
36
|
"jsdom-global": "3.0.2",
|
|
36
|
-
"mocha": "^11.
|
|
37
|
+
"mocha": "^11.7.5",
|
|
37
38
|
"rollup": "^4.53.2",
|
|
38
39
|
"ts-loader": "^9.5.4",
|
|
39
40
|
"tslib": "^2.8.1",
|