Skip to content

Commit

Permalink
refactor: util.go
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-mayer committed Sep 12, 2024
1 parent e9f21fb commit 033bc77
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions internal/pkg/values/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func GetLayerFromEnv() (Layer, error) {
return result, nil
}

// asExclusiveTimestamp removes the smallest unit of time, so the timestamp will be treated as exclusive
func asExclusiveTimestamp(inc time.Time) time.Time {
return inc.Add(-time.Nanosecond)
}
Expand All @@ -153,27 +154,17 @@ func isTimeFromSkippedToPreviousDay(timeFrom time.Time) bool {
return timeFrom.Year() == -1
}

// isTimeToSkppedToNextDay checks if timeTo skipped to the following day
// isTimeToSkippedToNextDay checks if timeTo skipped to the following day
func isTimeToSkippedToNextDay(timeTo time.Time) bool {
return asExclusiveTimestamp(timeTo).Day() == 2
}

// getWeekdayBefore returns the day before (it automatically checks if value is below 0 or above 6)
func getWeekdayBefore(weekday time.Weekday) time.Weekday {
if weekday == 0 {
weekday = 6
return weekday
} else {
return (weekday + 6) % 7
}
return (weekday + 6) % 7
}

// getWeekdayAfter returns the day after (it automatically checks if value is below 0 or above 6)
func getWeekdayAfter(weekday time.Weekday) time.Weekday {
if weekday == 6 {
weekday = 0
return weekday
} else {
return (weekday + 1) % 7
}
return (weekday + 1) % 7
}

0 comments on commit 033bc77

Please sign in to comment.