@bbn/bbn 2.0.71 → 2.0.73

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,6 +84,7 @@ 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
+ matchFormat(value: any, format: string): boolean;
87
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)
@@ -521,6 +521,15 @@ export class bbnDt {
521
521
  }
522
522
  return str;
523
523
  }
524
+ matchFormat(value, format) {
525
+ try {
526
+ this.parse(value, format);
527
+ return true;
528
+ }
529
+ catch (_a) {
530
+ return false;
531
+ }
532
+ }
524
533
  getWeekday(n, mode = 'long', locale) {
525
534
  return getWeekday(n, mode, locale);
526
535
  }
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);
@@ -215,7 +220,7 @@ const dt = (value, inputFormat = null, cls = 'auto') => {
215
220
  const d = value;
216
221
  return new bbnDtDateTime(d.getFullYear(), d.getMonth() + 1, d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());
217
222
  }
218
- throw new Error(_('Invalid date value: %s', value));
223
+ //throw new Error(_('Invalid date value: %s', value));
219
224
  };
220
225
  dt.locales = Object.create(null);
221
226
  dt.parse = parse;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "2.0.71",
3
+ "version": "2.0.73",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",