Skip to content

Commit

Permalink
Merge pull request #16 from oliver-hohn/correct-month-index
Browse files Browse the repository at this point in the history
Prevent quarter ends being assigned to next quarter
  • Loading branch information
oliver-hohn authored Dec 26, 2020
2 parents e390542 + 4e22361 commit 6b55da7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion organizemyfiles/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ func (f *File) GetQuarter() string {
return Undefined
}

switch quarterIndex := f.CreatedAt.Month() / 3; quarterIndex {
// Month() starts at 1 for January, and ends at 12 for December.
// By subtracting by -1 we can ensure that:
// Jan -> March is 0
// April -> June is 1
// July -> September is 2
// October -> December is 3
switch quarterIndex := (f.CreatedAt.Month() - 1) / 3; quarterIndex {
case 0:
return "00_jan_to_mar"
case 1:
Expand Down

0 comments on commit 6b55da7

Please sign in to comment.