Skip to content

Commit

Permalink
refactor: time/timeutil: use Day and Week in place of `Duration…
Browse files Browse the repository at this point in the history
…Day` and `DurationWeek`
  • Loading branch information
grokify committed Nov 12, 2023
1 parent 60af921 commit ff6d7a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
19 changes: 3 additions & 16 deletions time/timeutil/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,15 @@ package timeutil
import "time"

const (
Day = 24 * time.Hour
Week = 7 * Day

DaysPerWeek = float32(7)
HoursPerDay = float32(24)

SecondsPerYear = (365 * 24 * 60 * 60) + (6 * 60 * 60)
SecondsPerWeek = 7 * 24 * 60 * 60
SecondsPerDay = 24 * 60 * 60

// NanosPerSecond = int64(1000000000)
// NanosPerMicrosecond = NanosPerSecond / 1000000
// NanosPerMillisecond = NanosPerSecond / 1000
// NanosPerMinute = NanosPerSecond * 60
// NanosPerHour = NanosPerMinute * 60
// NanosPerDay = NanosPerHour * 24
// NanosPerWeek = NanosPerDay * 7
// NanosPerSecondSub1 = NanosPerSecond - 1
// NanosPerSecondSub1 = time.Second - 1

Day = 24 * time.Hour
Week = 7 * Day

DurationDay = 24 * time.Hour
DurationWeek = 7 * DurationDay

MonthsEN = `["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]`
)
6 changes: 3 additions & 3 deletions time/timeutil/duration_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (di DurationInfo) Duration(hoursPerDay, daysPerWeek float32) time.Duration
if hoursPerDay != 0 {
dur += time.Duration(di.Days) * time.Duration(hoursPerDay) * time.Hour
} else {
dur += time.Duration(di.Days) * DurationDay
dur += time.Duration(di.Days) * Day
}
}
if di.Weeks != 0 {
Expand All @@ -105,10 +105,10 @@ func (di DurationInfo) Duration(hoursPerDay, daysPerWeek float32) time.Duration
} else {
dur += time.Duration(di.Weeks) *
daysPerWeek *
DurationDay
Day
}
} else {
dur += time.Duration(di.Weeks) * DurationWeek
dur += time.Duration(di.Weeks) * Week
}
}
return dur
Expand Down

0 comments on commit ff6d7a3

Please sign in to comment.