Update dependency date-fns to v2 (#41027)

* Update dependency date-fns to v2

* Chore(dependencies): Update formatting used by date-fns

* kick drone

* Chore: Add parseISO to date strings passed to date-fn methods

* Prettier...

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
This commit is contained in:
renovate[bot] 2021-11-01 15:39:06 +00:00 committed by GitHub
parent 8157d3564b
commit c91bfcc1d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 15 deletions

View File

@ -1,5 +1,14 @@
import { e2e } from '@grafana/e2e';
import { addDays, addHours, differenceInCalendarDays, differenceInMinutes, format, isBefore, parse } from 'date-fns';
import {
addDays,
addHours,
differenceInCalendarDays,
differenceInMinutes,
format,
isBefore,
parseISO,
toDate,
} from 'date-fns';
e2e.scenario({
describeName: 'Dashboard time zone support',
@ -79,13 +88,13 @@ const isTimeCorrect = (inUtc: string, inTz: string, offset: number): boolean =>
return false;
}
const reference = format(new Date(), 'YYYY-MM-DD');
const reference = format(new Date(), 'yyyy-LL-dd');
const utcDate = parse(`${reference} ${inUtc}`);
const utcDateWithOffset = addHours(parse(`${reference} ${inUtc}`), offset);
const utcDate = toDate(parseISO(`${reference} ${inUtc}`));
const utcDateWithOffset = addHours(toDate(parseISO(`${reference} ${inUtc}`)), offset);
const dayDifference = differenceInCalendarDays(utcDate, utcDateWithOffset); // if the utcDate +/- offset is the day before/after then we need to adjust reference
const dayOffset = isBefore(utcDateWithOffset, utcDate) ? dayDifference * -1 : dayDifference;
const tzDate = addDays(parse(`${reference} ${inTz}`), dayOffset); // adjust tzDate with any dayOffset
const tzDate = addDays(toDate(parseISO(`${reference} ${inTz}`)), dayOffset); // adjust tzDate with any dayOffset
const diff = Math.abs(differenceInMinutes(utcDate, tzDate)); // use Math.abs if tzDate is in future
return diff <= Math.abs(offset * 60);

View File

@ -278,7 +278,7 @@
"d3-force": "^2.1.1",
"d3-scale-chromatic": "1.5.0",
"dangerously-set-html-content": "1.0.9",
"date-fns": "1.30.1",
"date-fns": "2.25.0",
"debounce-promise": "3.1.2",
"emotion": "10.0.27",
"eventemitter3": "4.0.0",

View File

@ -14276,13 +14276,6 @@ __metadata:
languageName: node
linkType: hard
"date-fns@npm:1.30.1, date-fns@npm:^1.27.2":
version: 1.30.1
resolution: "date-fns@npm:1.30.1"
checksum: 86b1f3269cbb1f3ee5ac9959775ea6600436f4ee2b78430cd427b41a0c9fabf740b1a5d401c085f3003539a6f4755c7c56c19fbd70ce11f6f673f6bc8075b710
languageName: node
linkType: hard
"date-fns@npm:2.21.3":
version: 2.21.3
resolution: "date-fns@npm:2.21.3"
@ -14290,13 +14283,20 @@ __metadata:
languageName: node
linkType: hard
"date-fns@npm:^2.16.1":
"date-fns@npm:2.25.0, date-fns@npm:^2.16.1":
version: 2.25.0
resolution: "date-fns@npm:2.25.0"
checksum: 8896dc1dde0ee5ef77616942423bfa11fa2017a5ac19457293b7aaedc8822ff94f0a14eaf93da573b09b601dc0149eb430988a046cc9f79a2eb15f8c66c9c50c
languageName: node
linkType: hard
"date-fns@npm:^1.27.2":
version: 1.30.1
resolution: "date-fns@npm:1.30.1"
checksum: 86b1f3269cbb1f3ee5ac9959775ea6600436f4ee2b78430cd427b41a0c9fabf740b1a5d401c085f3003539a6f4755c7c56c19fbd70ce11f6f673f6bc8075b710
languageName: node
linkType: hard
"date-format@npm:^0.0.0":
version: 0.0.0
resolution: "date-format@npm:0.0.0"
@ -18020,7 +18020,7 @@ __metadata:
d3-force: ^2.1.1
d3-scale-chromatic: 1.5.0
dangerously-set-html-content: 1.0.9
date-fns: 1.30.1
date-fns: 2.25.0
debounce-promise: 3.1.2
emotion: 10.0.27
enzyme: 3.11.0