This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4489 from minvws/release/2.61.0
Release/2.61.0
- Loading branch information
Showing
53 changed files
with
2,051 additions
and
1,561 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...onents/severity-indicator-tile/components/timeline/logic/get-timeline-bar-arrow-offset.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { createDateFromUnixTimestamp } from '~/utils/create-date-from-unix-timestamp'; | ||
import { middleOfDayInSeconds } from '@corona-dashboard/common'; | ||
|
||
// Returns the difference between two dates in days. | ||
const getDifferenceInDays = (start: Date, end: Date): number => { | ||
return Math.floor((end.getTime() - start.getTime()) / (1000 * 3600 * 24)); | ||
}; | ||
|
||
// Returns the date representing the middle of the day for the passed in dates. | ||
const getMiddleOfDayDates = (today: Date, startDate: number, endDate: number): Record<string, Date> => { | ||
const todayMiddleOfDaySeconds = middleOfDayInSeconds(today.getTime() / 1000); | ||
|
||
return { | ||
startOfIntervalDate: createDateFromUnixTimestamp(middleOfDayInSeconds(startDate)), | ||
endOfIntervalDate: createDateFromUnixTimestamp(middleOfDayInSeconds(endDate)), | ||
todayMiddleOfDayDate: createDateFromUnixTimestamp(todayMiddleOfDaySeconds), | ||
}; | ||
}; | ||
|
||
// Determines where to position the 'Vandaag' label on the timeline. | ||
export const getTimelineBarArrowOffset = (today: Date, startDate: number, endDate: number): number => { | ||
const { startOfIntervalDate, endOfIntervalDate, todayMiddleOfDayDate } = getMiddleOfDayDates(today, startDate, endDate); | ||
const numberOfDaysInInterval = getDifferenceInDays(startOfIntervalDate, endOfIntervalDate); | ||
const numberOfDaysFromStartToToday = getDifferenceInDays(startOfIntervalDate, todayMiddleOfDayDate); | ||
const arrowOffset = (numberOfDaysFromStartToToday / numberOfDaysInInterval) * 100; | ||
|
||
return arrowOffset; | ||
}; |
9 changes: 1 addition & 8 deletions
9
.../components/severity-indicator-tile/components/timeline/logic/get-timeline-range-dates.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.