@atlaskit/link-datasource 1.15.2 → 1.15.3

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,5 +1,11 @@
1
1
  # @atlaskit/link-datasource
2
2
 
3
+ ## 1.15.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#42661](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42661) [`c6abc68904d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c6abc68904d) - [ux] Fix date showing incorrectly and also update test data to check for the format it was failing for
8
+
3
9
  ## 1.15.2
4
10
 
5
11
  ### Patch Changes
@@ -7,5 +7,5 @@ exports.packageMetaData = exports.EVENT_CHANNEL = void 0;
7
7
  var EVENT_CHANNEL = exports.EVENT_CHANNEL = 'media';
8
8
  var packageMetaData = exports.packageMetaData = {
9
9
  packageName: "@atlaskit/link-datasource",
10
- packageVersion: "1.15.2"
10
+ packageVersion: "1.15.3"
11
11
  };
@@ -32,8 +32,14 @@ var DateTimeRenderType = function DateTimeRenderType(_ref) {
32
32
  testId = _ref$testId === void 0 ? DATETIME_TYPE_TEST_ID : _ref$testId,
33
33
  _ref$display = _ref.display,
34
34
  display = _ref$display === void 0 ? 'datetime' : _ref$display;
35
- var date = new Date(value);
36
35
  var intl = (0, _reactIntlNext.useIntl)();
36
+ /* In some cases we get a value of `2023-12-20` which when parsed by JS assumes meantime timezone, causing the date
37
+ to be one day off in some timezones. We want it to display the date without converting timezones and a solution
38
+ is to replace the hyphens with slashes. So it should be 20th Dec regardless of the timezone in this case.
39
+ See https://stackoverflow.com/a/31732581
40
+ */
41
+ var dateValue = /^\d{4}-\d{2}-\d{2}$/.exec(value) ? value.replace(/-/g, '/') : value;
42
+ var date = new Date(dateValue);
37
43
  if (!value || isNaN(date.getTime())) {
38
44
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
39
45
  }
@@ -1,5 +1,5 @@
1
1
  export const EVENT_CHANNEL = 'media';
2
2
  export const packageMetaData = {
3
3
  packageName: "@atlaskit/link-datasource",
4
- packageVersion: "1.15.2"
4
+ packageVersion: "1.15.3"
5
5
  };
@@ -21,8 +21,14 @@ const DateTimeRenderType = ({
21
21
  testId = DATETIME_TYPE_TEST_ID,
22
22
  display = 'datetime'
23
23
  }) => {
24
- const date = new Date(value);
25
24
  const intl = useIntl();
25
+ /* In some cases we get a value of `2023-12-20` which when parsed by JS assumes meantime timezone, causing the date
26
+ to be one day off in some timezones. We want it to display the date without converting timezones and a solution
27
+ is to replace the hyphens with slashes. So it should be 20th Dec regardless of the timezone in this case.
28
+ See https://stackoverflow.com/a/31732581
29
+ */
30
+ const dateValue = /^\d{4}-\d{2}-\d{2}$/.exec(value) ? value.replace(/-/g, '/') : value;
31
+ const date = new Date(dateValue);
26
32
  if (!value || isNaN(date.getTime())) {
27
33
  return /*#__PURE__*/React.createElement(React.Fragment, null);
28
34
  }
@@ -1,5 +1,5 @@
1
1
  export var EVENT_CHANNEL = 'media';
2
2
  export var packageMetaData = {
3
3
  packageName: "@atlaskit/link-datasource",
4
- packageVersion: "1.15.2"
4
+ packageVersion: "1.15.3"
5
5
  };
@@ -25,8 +25,14 @@ var DateTimeRenderType = function DateTimeRenderType(_ref) {
25
25
  testId = _ref$testId === void 0 ? DATETIME_TYPE_TEST_ID : _ref$testId,
26
26
  _ref$display = _ref.display,
27
27
  display = _ref$display === void 0 ? 'datetime' : _ref$display;
28
- var date = new Date(value);
29
28
  var intl = useIntl();
29
+ /* In some cases we get a value of `2023-12-20` which when parsed by JS assumes meantime timezone, causing the date
30
+ to be one day off in some timezones. We want it to display the date without converting timezones and a solution
31
+ is to replace the hyphens with slashes. So it should be 20th Dec regardless of the timezone in this case.
32
+ See https://stackoverflow.com/a/31732581
33
+ */
34
+ var dateValue = /^\d{4}-\d{2}-\d{2}$/.exec(value) ? value.replace(/-/g, '/') : value;
35
+ var date = new Date(dateValue);
30
36
  if (!value || isNaN(date.getTime())) {
31
37
  return /*#__PURE__*/React.createElement(React.Fragment, null);
32
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-datasource",
3
- "version": "1.15.2",
3
+ "version": "1.15.3",
4
4
  "description": "UI Components to support linking platform dataset feature",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"