Skip to content

Commit 4990e55

Browse files
committed
use correct first month value when not set while truncating to quarter
1 parent 9a25dd0 commit 4990e55

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

runtime/pkg/timeutil/timeutil.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ func TruncateTime(tm time.Time, tg TimeGrain, tz *time.Location, firstDay, first
125125
tm = tm.In(time.UTC)
126126
return tm
127127
case TimeGrainQuarter:
128+
if firstMonth < 1 {
129+
firstMonth = 1
130+
}
131+
if firstMonth > 12 {
132+
firstMonth = 12
133+
}
128134
monthsToSubtract := (3 + int(tm.Month()) - firstMonth%3) % 3
129135
tm = tm.In(tz)
130136
tm = time.Date(tm.Year(), tm.Month(), 1, 0, 0, 0, 0, tz)

0 commit comments

Comments
 (0)