cozy-ui 115.0.1 → 115.0.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [115.0.2](https://github.com/cozy/cozy-ui/compare/v115.0.1...v115.0.2) (2024-12-20)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **initFormat:** Ensure do not crash if no date is passed ([07564e7](https://github.com/cozy/cozy-ui/commit/07564e7))
7
+
1
8
  ## [115.0.1](https://github.com/cozy/cozy-ui/compare/v115.0.0...v115.0.1) (2024-12-20)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "115.0.1",
3
+ "version": "115.0.2",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -53,7 +53,11 @@ export const initFormat =
53
53
  const locale = provideDateFnsLocale(userLang, defaultLang)
54
54
  const ensureDate = date && typeof date === 'string' ? new Date(date) : date
55
55
 
56
- return format(ensureDate, formatStr, { locale, ...opts })
56
+ try {
57
+ return format(ensureDate, formatStr, { locale, ...opts })
58
+ } catch (error) {
59
+ console.error('Error in initFormat', error)
60
+ }
57
61
  }
58
62
 
59
63
  export const formatLocallyDistanceToNow = date => {
@@ -61,9 +61,14 @@ export var initFormat = function initFormat(userLang) {
61
61
  var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
62
62
  var locale = provideDateFnsLocale(userLang, defaultLang);
63
63
  var ensureDate = date && typeof date === 'string' ? new Date(date) : date;
64
- return format(ensureDate, formatStr, _objectSpread({
65
- locale: locale
66
- }, opts));
64
+
65
+ try {
66
+ return format(ensureDate, formatStr, _objectSpread({
67
+ locale: locale
68
+ }, opts));
69
+ } catch (error) {
70
+ console.error('Error in initFormat', error);
71
+ }
67
72
  };
68
73
  };
69
74
  export var formatLocallyDistanceToNow = function formatLocallyDistanceToNow(date) {