@bbn/bbn 2.0.11 → 2.0.13

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/date.d.ts CHANGED
@@ -23,6 +23,8 @@ declare class bbnDateTool {
23
23
  weekdaysShort?: string[];
24
24
  }): Date;
25
25
  constructor(value: any, inputFormat?: null | String);
26
+ parse(input: string, format: string): bbnDateTool;
27
+ matchFormat(value: any, format: string): boolean;
26
28
  toString(): string;
27
29
  year(v?: number): number | bbnDateTool;
28
30
  month(v?: number): number | bbnDateTool;
package/dist/date.js CHANGED
@@ -776,12 +776,7 @@ class bbnDateTool {
776
776
  __classPrivateFieldSet(this, _bbnDateTool_value, new Date(), "f");
777
777
  }
778
778
  else if (inputFormat) {
779
- try {
780
- __classPrivateFieldSet(this, _bbnDateTool_value, bbnDateTool.parse(value, inputFormat), "f");
781
- }
782
- catch (e) {
783
- throw new Error('Error parsing date with format "' + inputFormat + '": ' + e.message);
784
- }
779
+ __classPrivateFieldSet(this, _bbnDateTool_value, bbnDateTool.parse(value, inputFormat), "f");
785
780
  }
786
781
  else {
787
782
  if (t === 'number' || (isNumber(value) && value !== '')) {
@@ -823,6 +818,19 @@ class bbnDateTool {
823
818
  });
824
819
  }
825
820
  }
821
+ parse(input, format) {
822
+ const d = bbnDateTool.parse(input, format);
823
+ return new bbnDateTool(d);
824
+ }
825
+ matchFormat(value, format) {
826
+ try {
827
+ bbnDateTool.parse(value, format);
828
+ return true;
829
+ }
830
+ catch (_a) {
831
+ return false;
832
+ }
833
+ }
826
834
  toString() {
827
835
  return __classPrivateFieldGet(this, _bbnDateTool_value, "f") ? this.format() : '';
828
836
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "2.0.11",
3
+ "version": "2.0.13",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",