Fixed title for stats in case the weeks cross months

This commit is contained in:
マリウス 2020-10-17 19:53:13 +01:00
parent 631343388d
commit 86662a5a37
No known key found for this signature in database
GPG key ID: C228EF0A530AF06F

View file

@ -25,20 +25,23 @@ var statsCmd = &cobra.Command{
cal, _ := NewCalendar(entries) cal, _ := NewCalendar(entries)
today := time.Now() weekMinus0 := time.Now()
month, weeknumber := GetISOWeekInMonth(today) monthMinus0, weeknumberMinus0 := GetISOWeekInMonth(weekMinus0)
month0 := month - 1 monthMinus00 := monthMinus0 - 1
weeknumber0 := weeknumber - 1 weeknumberMinus00 := weeknumberMinus0 - 1
thisWeek := cal.GetOutputForWeekCalendar(today, month0, weeknumber0) thisWeek := cal.GetOutputForWeekCalendar(weekMinus0, monthMinus00, weeknumberMinus00)
oneWeekAgo := today.AddDate(0, 0, -7) weekMinus1 := weekMinus0.AddDate(0, 0, -7)
month, weeknumber = GetISOWeekInMonth(oneWeekAgo) monthMinus1, weeknumberMinus1 := GetISOWeekInMonth(weekMinus1)
month0 = month - 1 monthMinus10 := monthMinus1 - 1
weeknumber0 = weeknumber - 1 weeknumberMinus10 := weeknumberMinus1 - 1
previousWeek := cal.GetOutputForWeekCalendar(oneWeekAgo, month0, weeknumber0) previousWeek := cal.GetOutputForWeekCalendar(weekMinus1, monthMinus10, weeknumberMinus10)
if monthMinus00 == monthMinus10 {
fmt.Printf("\n%s\n\n", strings.ToUpper(today.Month().String())) fmt.Printf("\n%s\n\n", strings.ToUpper(weekMinus0.Month().String()))
} else {
fmt.Printf("\n%s / %s\n\n", strings.ToUpper(weekMinus0.Month().String()), strings.ToUpper(weekMinus1.Month().String()))
}
fmt.Printf("%s\n\n\n", OutputAppendRight(thisWeek, previousWeek, 16)) fmt.Printf("%s\n\n\n", OutputAppendRight(thisWeek, previousWeek, 16))
fmt.Printf("%s\n", cal.GetOutputForDistribution()) fmt.Printf("%s\n", cal.GetOutputForDistribution())