Skip to content

Commit b46650b

Browse files
committed
Fix off-by-one issue in drawing
1 parent 55f8885 commit b46650b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

git.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,10 @@ func PushAll(dir string, project string, branch string) error {
110110
return command(dir, "git", "push", "-fu", githubURL, branch)
111111
}
112112

113-
func pixelDaysAgo(x int, y int, w int, weeksAgo int) int {
114-
ago := int(time.Now().Weekday()) + 1 // start on a Sunday
115-
ago += (w - 1 - x + weeksAgo) * 7
116-
ago += (6 - y)
117-
return ago
113+
func pixelDaysAgo(x int, y int, width int, weeksAgo int) int {
114+
startDaysAgo := (width + weeksAgo) * 7
115+
startDaysAgo += int(time.Now().Weekday())
116+
return startDaysAgo - (x * 7) - y
118117
}
119118

120119
func drawPixel(dir string, f *os.File, px GraphPixel, pixelChrs string) error {

0 commit comments

Comments
 (0)