From e99baa6a7b9e08a3041ca7a75422e275e9f6b323 Mon Sep 17 00:00:00 2001 From: Sakai-san Date: Fri, 16 Apr 2021 00:13:58 +0200 Subject: [PATCH 1/7] Improvement/MC-21331, PR init code comment. --- .../TimeRangeNavigationBar/TimeRangeNavigationBar.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx b/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx index 8e15dc7c9..8d868dd58 100644 --- a/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx +++ b/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx @@ -27,7 +27,8 @@ const TimeRangeNavigationBar = (props) => { /* eslint-disable-next-line react/display-name */ TimeRangeNavigationBar.renderCurrentTimeRange = (from, to, timezone) => { - + // TODO: replace Intl.DateTimeFormat by a formatter which is unified, meant not depending on user's setting. + const locale = new Intl.DateTimeFormat('de', { timeZone: timezone, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', }); From edde1bb5f325a6fb32aed3042bf1a0cf4ea163d0 Mon Sep 17 00:00:00 2001 From: Sakai-san Date: Fri, 16 Apr 2021 00:18:59 +0200 Subject: [PATCH 2/7] Fix linting. --- .../TimeRangeNavigationBar/TimeRangeNavigationBar.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx b/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx index 8d868dd58..9024553b0 100644 --- a/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx +++ b/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx @@ -28,7 +28,6 @@ const TimeRangeNavigationBar = (props) => { /* eslint-disable-next-line react/display-name */ TimeRangeNavigationBar.renderCurrentTimeRange = (from, to, timezone) => { // TODO: replace Intl.DateTimeFormat by a formatter which is unified, meant not depending on user's setting. - const locale = new Intl.DateTimeFormat('de', { timeZone: timezone, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', }); From 2232f885c815f58bbac0682a313dbe91b8ae8ca7 Mon Sep 17 00:00:00 2001 From: Sakai-san Date: Fri, 16 Apr 2021 00:20:46 +0200 Subject: [PATCH 3/7] Code comment. --- .../TimeRangeNavigationBar/TimeRangeNavigationBar.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx b/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx index 9024553b0..341d2faf8 100644 --- a/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx +++ b/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx @@ -27,7 +27,7 @@ const TimeRangeNavigationBar = (props) => { /* eslint-disable-next-line react/display-name */ TimeRangeNavigationBar.renderCurrentTimeRange = (from, to, timezone) => { - // TODO: replace Intl.DateTimeFormat by a formatter which is unified, meant not depending on user's setting. + // TODO: replace Intl.DateTimeFormat by a formatter which is unified, means not depending on the user's settings. const locale = new Intl.DateTimeFormat('de', { timeZone: timezone, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', }); From 99efe8a36651868f34791809bf0b4e637692a512 Mon Sep 17 00:00:00 2001 From: Sakai-san Date: Fri, 16 Apr 2021 17:30:37 +0200 Subject: [PATCH 4/7] Improvement/MC-21331. Story done. --- pyrene/package-lock.json | 7 +++---- pyrene/package.json | 2 +- .../TimeRangeNavigationBar.jsx | 13 +++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pyrene/package-lock.json b/pyrene/package-lock.json index 74d294916..38c478cdc 100644 --- a/pyrene/package-lock.json +++ b/pyrene/package-lock.json @@ -5861,10 +5861,9 @@ "integrity": "sha512-sAJVKx/FqrLYHAQeN7VpJrPhagZc9R4ImZIWYRFZaaohR3KzmuK88touwsSwSVT8Qcbd4zoDsnGfX4GFB4imyQ==" }, "date-fns-tz": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/date-fns-tz/-/date-fns-tz-1.1.3.tgz", - "integrity": "sha512-mD26WkejWz842RggjFrKsY6ehGgyBQSJ209mn83/vsjhgQ5WbdVvBzJ0CuosnGdklDxOvOppQ/wn1UgvTOPKPw==", - "dev": true + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/date-fns-tz/-/date-fns-tz-1.1.4.tgz", + "integrity": "sha512-lQ+FF7xUxxRuRqIY7H/lagnT3PhhSnnvtGHzjE5WZKwRyLU7glJfLys05SZ7zHlEr6RXWiqkmgWq4nCkcElR+g==" }, "debug": { "version": "4.3.1", diff --git a/pyrene/package.json b/pyrene/package.json index 9927387d9..fe9e416ef 100644 --- a/pyrene/package.json +++ b/pyrene/package.json @@ -60,7 +60,6 @@ "babel-plugin-typescript-to-proptypes": "^1.4.1", "copy-webpack-plugin": "^6.2.0", "css-loader": "^3.6.0", - "date-fns-tz": "^1.1.3", "enzyme": "^3.3.0", "enzyme-adapter-react-16": "^1.15.5", "eslint": "^7.10.0", @@ -99,6 +98,7 @@ "dependencies": { "classnames": "^2.2.5", "date-fns": "^2.16.1", + "date-fns-tz": "^1.1.4", "prop-types": "^15.6.1", "react-select": "^3.1.1", "react-table": "^6.8.6", diff --git a/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx b/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx index 341d2faf8..112c7ec66 100644 --- a/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx +++ b/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx @@ -1,7 +1,9 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { differenceInMinutes } from 'date-fns'; +import { differenceInMinutes, getTime, format } from 'date-fns'; +import { zonedTimeToUtc } from 'date-fns-tz'; + import ArrowSelector from './ArrowSelector/ArrowSelector'; @@ -27,12 +29,11 @@ const TimeRangeNavigationBar = (props) => { /* eslint-disable-next-line react/display-name */ TimeRangeNavigationBar.renderCurrentTimeRange = (from, to, timezone) => { - // TODO: replace Intl.DateTimeFormat by a formatter which is unified, means not depending on the user's settings. - const locale = new Intl.DateTimeFormat('de', { - timeZone: timezone, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', - }); + const localFrom = getTime(zonedTimeToUtc(new Date(from), timezone)); + const localTo = getTime(zonedTimeToUtc(new Date(to), timezone)); + const pattern = 'dd.MM.yyyy, HH:mm'; - return `${locale.format(from)} - ${locale.format(to)}`; + return `${format(localFrom, pattern) - format(localTo, pattern)}`; }; TimeRangeNavigationBar.defaultProps = { From 12a8b7e26b3a6f9dc7b5eedc74d7b98d81905b5d Mon Sep 17 00:00:00 2001 From: Sakai-san Date: Fri, 16 Apr 2021 22:56:38 +0200 Subject: [PATCH 5/7] Fix template literal. --- .../TimeRangeNavigationBar/TimeRangeNavigationBar.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx b/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx index 112c7ec66..b77e124e8 100644 --- a/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx +++ b/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx @@ -33,7 +33,7 @@ TimeRangeNavigationBar.renderCurrentTimeRange = (from, to, timezone) => { const localTo = getTime(zonedTimeToUtc(new Date(to), timezone)); const pattern = 'dd.MM.yyyy, HH:mm'; - return `${format(localFrom, pattern) - format(localTo, pattern)}`; + return `${format(localFrom, pattern)} - ${format(localTo, pattern)}`; }; TimeRangeNavigationBar.defaultProps = { From 6667a823b08f4922f9aa27610031a36349cd9457 Mon Sep 17 00:00:00 2001 From: Sakai-san Date: Fri, 16 Apr 2021 23:31:09 +0200 Subject: [PATCH 6/7] Compute local time based on utc time. --- .../TimeRangeNavigationBar/TimeRangeNavigationBar.jsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx b/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx index b77e124e8..ad981f081 100644 --- a/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx +++ b/pyrene/src/components/TimeRangeSelector/TimeRangeNavigationBar/TimeRangeNavigationBar.jsx @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { differenceInMinutes, getTime, format } from 'date-fns'; -import { zonedTimeToUtc } from 'date-fns-tz'; +import { utcToZonedTime } from 'date-fns-tz'; import ArrowSelector from './ArrowSelector/ArrowSelector'; @@ -27,10 +27,9 @@ const TimeRangeNavigationBar = (props) => { ); }; -/* eslint-disable-next-line react/display-name */ TimeRangeNavigationBar.renderCurrentTimeRange = (from, to, timezone) => { - const localFrom = getTime(zonedTimeToUtc(new Date(from), timezone)); - const localTo = getTime(zonedTimeToUtc(new Date(to), timezone)); + const localFrom = getTime(utcToZonedTime(new Date(from), timezone)); + const localTo = getTime(utcToZonedTime(new Date(to), timezone)); const pattern = 'dd.MM.yyyy, HH:mm'; return `${format(localFrom, pattern)} - ${format(localTo, pattern)}`; From 34b434a94375c38c4a889b7d30999d034ee54a46 Mon Sep 17 00:00:00 2001 From: Sakai-san Date: Mon, 19 Apr 2021 08:56:50 +0200 Subject: [PATCH 7/7] Align github action node version with main project node version. --- .github/workflows/lint.yml | 8 ++++---- .github/workflows/test.yml | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b937d6753..0cc9e9f3f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: '14' + node-version: '12' - name: Lint pyrene run: (cd pyrene && npm install && npm run lint) tuktuktwo: @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: '14' + node-version: '12' - name: Lint tuktuktwo run: (cd tuktuktwo && npm install && npm run lint) pyrene-graphs: @@ -31,7 +31,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: '14' + node-version: '12' - name: Lint pyrene-graphs run: (cd pyrene-graphs && npm install && npm run lint) kitchensink: @@ -41,6 +41,6 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: '14' + node-version: '12' - name: Lint kitchensink run: (cd kitchensink && npm install && npm run lint) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4460557a6..033965fc6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: '14' + node-version: '12' - name: Test pyrene run: (cd pyrene && npm install && npm test) - name: Build pyrene @@ -26,7 +26,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: '14' + node-version: '12' - name: Test tuktuktwo run: (cd tuktuktwo && npm install && npm test) - name: Build tuktuktwo @@ -38,7 +38,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: '14' + node-version: '12' - name: Test pyrene-graphs run: (cd pyrene-graphs && npm install && npm test) - name: Build pyrene-graphs