From c5341996f8da4cfb3986d825d34cad29b03f1e7d Mon Sep 17 00:00:00 2001 From: Wynd Date: Sat, 2 Nov 2024 15:47:19 +0200 Subject: [PATCH] Fixed empty space being added for the first day of the heatmap if its also first day of the month --- src/heatmap.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/heatmap.rs b/src/heatmap.rs index 2f23fd6..e48fdc9 100644 --- a/src/heatmap.rs +++ b/src/heatmap.rs @@ -55,15 +55,20 @@ impl Heatmap { } } + // Track the very first day of the heatmap, as we don't want the extra spacing in front of + // those. + let mut first_day = true; + while current_day <= until { if split_months { - // If current day is the first of the month we add 2 weeks worth of empty space so - // months are more visible - if current_day.day0() == 0 { + // If current day is the first of the month, but not the first day of the heatmap + // we add 2 weeks worth of empty space so months are more visible + if !first_day && current_day.day0() == 0 { for i in 0..14 { heatmap.data[(i as usize) % 7].push(-1); } } + first_day = false; } let month_name = current_day.format("%b").to_string();