Simplified the split-months option
parent
5622df82a9
commit
95bb51dfd4
|
@ -52,6 +52,16 @@ impl Heatmap {
|
||||||
}
|
}
|
||||||
|
|
||||||
while current_day <= until {
|
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 {
|
||||||
|
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 {
|
||||||
|
@ -74,19 +84,6 @@ impl Heatmap {
|
||||||
None => heatmap.data[day_of_week as usize].push(0),
|
None => heatmap.data[day_of_week as usize].push(0),
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -94,13 +91,6 @@ impl Heatmap {
|
||||||
heatmap
|
heatmap
|
||||||
}
|
}
|
||||||
|
|
||||||
fn last_day_of_month(&self, year: i32, month: u32) -> NaiveDate {
|
|
||||||
NaiveDate::from_ymd_opt(year, month + 1, 1)
|
|
||||||
.unwrap_or_else(|| NaiveDate::from_ymd(year + 1, 1, 1))
|
|
||||||
.pred_opt()
|
|
||||||
.unwrap_or_default()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn months_row(&self) -> String {
|
fn months_row(&self) -> String {
|
||||||
let mut row = " ".to_string();
|
let mut row = " ".to_string();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue