mirror of
https://github.com/luckjiawei/podux.git
synced 2026-11-30 01:06:47 +00:00
16 lines
399 B
Go
16 lines
399 B
Go
package utils
|
|
|
|
import "time"
|
|
|
|
// RoundDownTo10Minutes rounds down a time to the nearest 10-minute mark
|
|
// Example: 10:07:30 -> 10:00:00, 10:15:45 -> 10:10:00, 10:20:00 -> 10:20:00
|
|
func RoundDownTo10Minutes(t time.Time) time.Time {
|
|
minutes := t.Minute()
|
|
roundedMinutes := (minutes / 10) * 10
|
|
return time.Date(
|
|
t.Year(), t.Month(), t.Day(),
|
|
t.Hour(), roundedMinutes, 0, 0,
|
|
t.Location(),
|
|
)
|
|
}
|