@@ -73,8 +73,11 @@ func applyCostDefaults(q *oci.CostQuery) {
|
||||
|
||||
func alignDown(t time.Time, granularity string) time.Time {
|
||||
t = t.UTC()
|
||||
if granularity == "MONTHLY" {
|
||||
switch granularity {
|
||||
case "MONTHLY":
|
||||
return time.Date(t.Year(), t.Month(), 1, 0, 0, 0, 0, time.UTC)
|
||||
case "HOURLY":
|
||||
return t.Truncate(time.Hour)
|
||||
}
|
||||
return t.Truncate(24 * time.Hour)
|
||||
}
|
||||
@@ -84,8 +87,11 @@ func alignUp(t time.Time, granularity string) time.Time {
|
||||
if down.Equal(t.UTC()) {
|
||||
return down
|
||||
}
|
||||
if granularity == "MONTHLY" {
|
||||
switch granularity {
|
||||
case "MONTHLY":
|
||||
return down.AddDate(0, 1, 0)
|
||||
case "HOURLY":
|
||||
return down.Add(time.Hour)
|
||||
}
|
||||
return down.AddDate(0, 0, 1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user