@bbn/bbn 2.0.70 → 2.0.72

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.
@@ -84,7 +84,8 @@ export declare abstract class bbnDt<TValue extends bbnDtTemporal> {
84
84
  get WW(): string;
85
85
  get W(): string;
86
86
  format(format?: string): string;
87
- getWeekday(mode?: string, locale?: string): string;
87
+ matchFormat(value: any, format: string): boolean;
88
+ getWeekday(n: 0 | 1 | 2 | 3 | 4 | 5 | 6, mode?: string, locale?: string): string;
88
89
  /**
89
90
  * Returns a NEW date that is the next (or previous if past=true)
90
91
  * occurrence of the given weekday, starting from this.#value.
@@ -101,5 +102,6 @@ export declare abstract class bbnDt<TValue extends bbnDtTemporal> {
101
102
  fromDate(date: any, unit?: string): string;
102
103
  startOf(unit?: string): bbnDt<any>;
103
104
  endOf(unit?: string): bbnDt<any>;
105
+ clone(): bbnDt<any>;
104
106
  }
105
107
  export default bbnDt;
@@ -521,12 +521,17 @@ export class bbnDt {
521
521
  }
522
522
  return str;
523
523
  }
524
- getWeekday(mode = 'long', locale) {
525
- const wd = this.weekday();
526
- if (typeof wd === 'number') {
527
- return getWeekday(wd, mode, locale);
524
+ matchFormat(value, format) {
525
+ try {
526
+ this.parse(value, format);
527
+ return true;
528
+ }
529
+ catch (_a) {
530
+ return false;
528
531
  }
529
- return undefined;
532
+ }
533
+ getWeekday(n, mode = 'long', locale) {
534
+ return getWeekday(n, mode, locale);
530
535
  }
531
536
  /**
532
537
  * Returns a NEW date that is the next (or previous if past=true)
@@ -833,6 +838,9 @@ export class bbnDt {
833
838
  throw new Error("Unsupported kind in endOf");
834
839
  }
835
840
  }
841
+ clone() {
842
+ return this.withValue(this.value);
843
+ }
836
844
  }
837
845
  _bbnDt_value = new WeakMap();
838
846
  /** System time zone ID (e.g. "Europe/Rome") */
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"): bbnDt<any> | bbnDtDateTime;
4
+ (value: any, inputFormat?: null | String, cls?: "auto" | "zoned" | "dateTime" | "date" | "time" | "yearMonth" | "monthDay"): any;
6
5
  locales: any;
7
6
  parse: typeof parse;
8
7
  guessFormat: typeof guessFormat;
package/dist/dt.js CHANGED
@@ -196,7 +196,12 @@ const dt = (value, inputFormat = null, cls = 'auto') => {
196
196
  }
197
197
  if (typeof value === 'string') {
198
198
  if (inputFormat) {
199
- return parse(value, inputFormat, cls);
199
+ let parsed;
200
+ try {
201
+ parsed = parse(value, inputFormat, cls);
202
+ return parsed;
203
+ }
204
+ catch (e) { }
200
205
  }
201
206
  else {
202
207
  const format = guessFormat(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "2.0.70",
3
+ "version": "2.0.72",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",