mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
15 lines
463 B
Go
15 lines
463 B
Go
// Package timeutil provides a func for getting start of week of given time.
|
|
package timeutil
|
|
|
|
import "time"
|
|
|
|
// StartOfDay returns time at start of day of t.
|
|
func StartOfDay(t time.Time) time.Time {
|
|
return time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
|
|
}
|
|
|
|
// StartOfWeek returns time at start of week of t.
|
|
func StartOfWeek(t time.Time) time.Time {
|
|
return time.Date(t.Year(), t.Month(), t.Day()-int(t.Weekday()), 0, 0, 0, 0, t.Location())
|
|
}
|