From 4f301a4ce450d1decfac4b05147a99c7c7e3979d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9E=E3=83=AA=E3=82=A6=E3=82=B9?= Date: Sat, 17 Oct 2020 21:14:22 +0100 Subject: [PATCH] Implemented error handling for "over-tracking" --- z/calendar.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/z/calendar.go b/z/calendar.go index 0c8c0be..a09a894 100644 --- a/z/calendar.go +++ b/z/calendar.go @@ -145,6 +145,11 @@ func (calendar *Calendar) GetOutputForWeekCalendar(date time.Time, month int, we totalHours = totalHours.Add(stat.Hours) } + if dayHours.GreaterThan(decimal.NewFromInt(24)) { + fmt.Printf("%s %s of week %d in month %d has more than 24h tracked; cutting at 24h now\n", CharError, day, (month+1), (week+1)) + dayHours = decimal.NewFromInt(24) + } + bar := GetOutputBarForHours(dayHours, calendar.Months[month].Weeks[week].Statistics[day]) bars = append(bars, bar) }