1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00
cowyo/vendor/github.com/shurcooL/go/timeutil/timeutil.go

15 lines
463 B
Go
Raw Normal View History

2017-10-03 21:43:55 +03:00
// 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())
}