Skip to content

Commit

Permalink
vinvoor: retain scan time
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed Sep 5, 2024
1 parent ba7ea28 commit 06cfd69
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion vinvoor/src/overview/heatmap/Day.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const Day: FC<DayProps> = ({

const data = useMemo<DayData>(() => {
const normalizedScans = [...scans];
normalizedScans.forEach(scan => scan.scanTime.setHours(0, 0, 0, 0));
// normalizedScans.forEach(scan => scan.scanTime.setHours(0, 0, 0, 0));
const formattedScans = formatData(normalizedScans);

const start = new Date(
Expand Down
11 changes: 9 additions & 2 deletions vinvoor/src/overview/heatmap/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@ export const getColumnCountMonths = (startDate: Date, endDate: Date) => {

export const getMondayIndexedDay = (date: Date) => (date.getDay() + 6) % 7;

const getNormalizedTime = (date: Date) => {
const result = new Date(date);
result.setHours(0, 0, 0, 0);
return result;
};

export const formatData = (scans: Scan[]) => {
const result: Record<number, HeatmapValue> = {};
scans.forEach(scan => {
result[scan.scanTime.getTime()] = {
date: scan.scanTime,
const date = getNormalizedTime(scan.scanTime);
result[date.getTime()] = {
date: date,
count: 1,
};
});
Expand Down
5 changes: 3 additions & 2 deletions vinvoor/src/overview/streak/Streak.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ const isStreakDay = (date1: Date, date2: Date) => {
const getStreak = (scans: readonly Scan[]): [boolean, number] => {
const dates = scans
.map(scan => {
scan.scanTime.setHours(0, 0, 0, 0);
return scan.scanTime;
const date = new Date(scan.scanTime);
date.setHours(0, 0, 0, 0);
return date;
})
.filter((value, index, array) => {
return (
Expand Down

0 comments on commit 06cfd69

Please sign in to comment.