Fixed the split-months heatmap being 1 day off

master
Wynd 2024-09-01 10:52:10 +03:00
parent 468f6a4eba
commit 5622df82a9
1 changed files with 14 additions and 14 deletions

View File

@ -52,19 +52,6 @@ impl Heatmap {
} }
while current_day <= until { while current_day <= until {
if split_months {
let last_day_of_month =
heatmap.last_day_of_month(current_day.year_ce().1 as i32, current_day.month());
// If current day is the last of the month we add 2 weeks worth of empty space so
// months are more visible
if last_day_of_month == current_day {
for i in 0..14 {
heatmap.data[(i as usize) % 7].push(-1);
}
}
}
let month_name = current_day.format("%b").to_string(); let month_name = current_day.format("%b").to_string();
if current_day == since { if current_day == since {
@ -86,7 +73,20 @@ impl Heatmap {
} }
None => heatmap.data[day_of_week as usize].push(0), None => heatmap.data[day_of_week as usize].push(0),
} }
// println!("{} {value:?}", current_day);
if split_months {
let last_day_of_month =
heatmap.last_day_of_month(current_day.year_ce().1 as i32, current_day.month());
// If current day is the last of the month we add 2 weeks worth of empty space so
// months are more visible
if last_day_of_month == current_day {
for i in 0..14 {
heatmap.data[(i as usize) % 7].push(-1);
}
}
}
current_day += Duration::days(1); current_day += Duration::days(1);
day_of_week = current_day.weekday().num_days_from_monday() % 7; day_of_week = current_day.weekday().num_days_from_monday() % 7;
} }