Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[timeline] fix display of unit above #142

Merged
merged 13 commits into from
Nov 6, 2023

Conversation

CrisGrud
Copy link
Collaborator

This PR closes #140

@CrisGrud CrisGrud requested a review from luciob October 31, 2023 10:39
@CrisGrud CrisGrud linked an issue Oct 31, 2023 that may be closed by this pull request
Comment on lines 11 to 12
dayInfo?: { thisMonth?: number; untilNow?: number; backHour: boolean; forNowHour: boolean }[];
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a type for this data structure

Comment on lines 20 to 38
const dayInfo: { thisMonth?: number; untilNow?: number; backHour: boolean; forNowHour: boolean }[] = [];
if (unitAbove === "month" || unitAbove === "day") {
aboveTimeBlocks.forEach((column, index) => {
const hrs = column.end!.diff(column.start!, "hour").hours;
const month = getMonth(column);
const year = getYear(column);
const currentMonthDays = daysInMonth(Number(month), Number(year));
const bchour = hrs > 24 ? true : false;
if (index === 0) {
const startDay = getStartMonthsDay(interval.start!);
const daysToMonthEnd = currentMonthDays - Number(startDay) + 1;
dayInfo.push({ thisMonth: daysToMonthEnd, untilNow: daysToMonthEnd, backHour: bchour, forNowHour: false });
return;
}
const forNowHour = dayInfo[index - 1].forNowHour ? true : dayInfo[index - 1].backHour ? true : false;
const n = dayInfo[index - 1].untilNow! + currentMonthDays;
dayInfo.push({ thisMonth: currentMonthDays, untilNow: n, backHour: bchour, forNowHour: forNowHour });
});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use a memo here if possible

@CrisGrud CrisGrud requested a review from luciob November 6, 2023 16:05
blockEnd = intervalEnd;
}

logError("Adding Block", `${blockStart.toFormat("dd/MM/yy HH:mm")} > ${blockEnd.toFormat("dd/MM/yy HH:mm")}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove logError call or switch to logDebug, or delete

@CrisGrud CrisGrud merged commit 042e2eb into main Nov 6, 2023
@CrisGrud CrisGrud deleted the 140-timeline-fix-display-of-unit-above branch November 6, 2023 16:35
@luciob
Copy link
Member

luciob commented Nov 6, 2023

🎉 This PR is included in version 1.16.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@luciob luciob added the released label Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Timeline] Fix display of unit above
2 participants