From 56fa219d2dc1805f5d4e3f75fb09fd323c487669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petar=20Kapri=C5=A1?= Date: Fri, 4 Mar 2022 16:36:25 +0100 Subject: [PATCH] Edit wall-movement functions in drw for clarity --- drw/wall.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drw/wall.go b/drw/wall.go index e11ac05..5945b3e 100644 --- a/drw/wall.go +++ b/drw/wall.go @@ -44,8 +44,8 @@ func monthHeight(m time.Month) int { func bottomOfMonth(m time.Month, w time.Weekday) (time time.Time) { last := lastDay(m) - day := last.Day() + day := last.Day() if w > last.Weekday() { day -= 7 } @@ -102,7 +102,7 @@ func MoveUp() { newTime := util.SelTime.AddDate(0, 0, -7) if newTime.Month() == util.SelTime.Month() { util.SelTime = newTime - } else if int(util.SelTime.Month()) > monthsWide { + } else if int(util.SelTime.Month())-monthsWide >= 1 { newMonth := util.SelTime.Month() - time.Month(monthsWide) util.SelTime = bottomOfMonth(newMonth, weekday) } @@ -113,7 +113,7 @@ func MoveDown() { newTime := util.SelTime.AddDate(0, 0, +7) if newTime.Month() == util.SelTime.Month() { util.SelTime = newTime - } else if int(util.SelTime.Month()) <= (12-1)/monthsWide*monthsWide { + } else if int(util.SelTime.Month())+monthsWide <= 12 { newMonth := util.SelTime.Month() + time.Month(monthsWide) util.SelTime = topOfMonth(newMonth, weekday) } @@ -122,7 +122,7 @@ func MoveDown() { func MoveRight() { if util.SelTime.Weekday() != time.Sunday && util.SelTime.Day() != lastDay(util.SelTime.Month()).Day() { util.SelTime = util.SelTime.AddDate(0, 0, 1) - } else if int(util.SelTime.Month())%monthsWide != 0 && int(util.SelTime.Month()) != 12 { + } else if int(util.SelTime.Month())%monthsWide != 0 && util.SelTime.Month() != time.December { util.SelTime = leftmostInRow(util.SelTime.Month()+1, rowInMonth(util.SelTime.Month(), util.SelTime.Day())) } }