@formatjs/intl-datetimeformat 6.12.4 → 6.12.6

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.
@@ -4,16 +4,31 @@ import { toLocaleString as _toLocaleString, toLocaleDateString as _toLocaleDateS
4
4
  defineProperty(Intl, 'DateTimeFormat', { value: DateTimeFormat });
5
5
  defineProperty(Date.prototype, 'toLocaleString', {
6
6
  value: function toLocaleString(locales, options) {
7
- return _toLocaleString(this, locales, options);
7
+ try {
8
+ return _toLocaleString(this, locales, options);
9
+ }
10
+ catch (error) {
11
+ return 'Invalid Date';
12
+ }
8
13
  },
9
14
  });
10
15
  defineProperty(Date.prototype, 'toLocaleDateString', {
11
16
  value: function toLocaleDateString(locales, options) {
12
- return _toLocaleDateString(this, locales, options);
17
+ try {
18
+ return _toLocaleDateString(this, locales, options);
19
+ }
20
+ catch (error) {
21
+ return 'Invalid Date';
22
+ }
13
23
  },
14
24
  });
15
25
  defineProperty(Date.prototype, 'toLocaleTimeString', {
16
26
  value: function toLocaleTimeString(locales, options) {
17
- return _toLocaleTimeString(this, locales, options);
27
+ try {
28
+ return _toLocaleTimeString(this, locales, options);
29
+ }
30
+ catch (error) {
31
+ return 'Invalid Date';
32
+ }
18
33
  },
19
34
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formatjs/intl-datetimeformat",
3
- "version": "6.12.4",
3
+ "version": "6.12.6",
4
4
  "description": "Intl.DateTimeFormat polyfill",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -23,11 +23,11 @@
23
23
  "homepage": "https://github.com/formatjs/formatjs#readme",
24
24
  "dependencies": {
25
25
  "tslib": "^2.4.0",
26
- "@formatjs/ecma402-abstract": "1.18.3",
27
- "@formatjs/intl-localematcher": "0.5.4"
26
+ "@formatjs/intl-localematcher": "0.5.4",
27
+ "@formatjs/ecma402-abstract": "2.0.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@formatjs/intl-locale": "3.4.6",
30
+ "@formatjs/intl-locale": "4.0.0",
31
31
  "@formatjs/intl-getcanonicallocales": "2.3.0"
32
32
  }
33
33
  }
package/polyfill-force.js CHANGED
@@ -6,16 +6,31 @@ var to_locale_string_1 = require("./src/to_locale_string");
6
6
  (0, ecma402_abstract_1.defineProperty)(Intl, 'DateTimeFormat', { value: _1.DateTimeFormat });
7
7
  (0, ecma402_abstract_1.defineProperty)(Date.prototype, 'toLocaleString', {
8
8
  value: function toLocaleString(locales, options) {
9
- return (0, to_locale_string_1.toLocaleString)(this, locales, options);
9
+ try {
10
+ return (0, to_locale_string_1.toLocaleString)(this, locales, options);
11
+ }
12
+ catch (error) {
13
+ return 'Invalid Date';
14
+ }
10
15
  },
11
16
  });
12
17
  (0, ecma402_abstract_1.defineProperty)(Date.prototype, 'toLocaleDateString', {
13
18
  value: function toLocaleDateString(locales, options) {
14
- return (0, to_locale_string_1.toLocaleDateString)(this, locales, options);
19
+ try {
20
+ return (0, to_locale_string_1.toLocaleDateString)(this, locales, options);
21
+ }
22
+ catch (error) {
23
+ return 'Invalid Date';
24
+ }
15
25
  },
16
26
  });
17
27
  (0, ecma402_abstract_1.defineProperty)(Date.prototype, 'toLocaleTimeString', {
18
28
  value: function toLocaleTimeString(locales, options) {
19
- return (0, to_locale_string_1.toLocaleTimeString)(this, locales, options);
29
+ try {
30
+ return (0, to_locale_string_1.toLocaleTimeString)(this, locales, options);
31
+ }
32
+ catch (error) {
33
+ return 'Invalid Date';
34
+ }
20
35
  },
21
36
  });