Skip to content

Commit

Permalink
add 30 minute 'lunch' when working for 6 hours (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-knurek authored Dec 3, 2020
1 parent aeec1e2 commit fa4e1db
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/reporting/increment.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ func incrementTime(data Years, t time.Time) (Years, int) {
if data[y] != nil {
if data[y][m] != nil {
cur = data[y][m][d] + 1
// if worked 6 hours, add a 30 minute "lunch"
if cur == 361 {
cur += 30
}
data[y][m][d] = cur
} else {
data[y][m] = Days{d: 1}
Expand Down
14 changes: 14 additions & 0 deletions pkg/reporting/increment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ func Test_incrementTime(t *testing.T) {
want: Years{"2020": {"December": {"31": 487}}, "2021": {"January": {"1": 1}}},
wantMinutes: 1,
},
{
name: "30 minute lunch",
y: Years{"2020": {"December": {"31": 360}}},
t: sameHour,
want: Years{"2020": {"December": {"31": 391}}},
wantMinutes: 391,
},
{
name: "30 minute lunch was missed",
y: Years{"2020": {"December": {"31": 361}}},
t: sameHour,
want: Years{"2020": {"December": {"31": 362}}},
wantMinutes: 362,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit fa4e1db

Please sign in to comment.