Skip to content

Commit

Permalink
refactor: change between algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
rof20004 committed Nov 15, 2022
1 parent e94e497 commit 67187b4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions period.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ type Period struct {
Days int
}

func (p *Period) Between(start, end time.Time) {
func newPeriod(years, months, days int) Period {
return Period{years, months, days}
}

func Between(start, end time.Time) Period {
startYear, startMonth, startDay := start.Date()
endYear, endMonth, endDay := end.Date()

Expand All @@ -38,9 +42,7 @@ func (p *Period) Between(start, end time.Time) {
var years = totalMonths / 12
var months = totalMonths % 12

p.Years = years
p.Months = months
p.Days = days
return newPeriod(years, months, days)
}

func getProlepticMonth(year, month int) int {
Expand Down

0 comments on commit 67187b4

Please sign in to comment.