2
0
mirror of https://github.com/miguelmota/cointop synced 2024-11-14 18:12:57 +00:00
cointop/pkg/timeutil/timeutil.go
2020-11-18 20:37:40 -08:00

25 lines
470 B
Go

package timeutil
import "time"
// Now now struct
type Now struct {
time.Time
}
// New initialize Now with time
func New(t time.Time) *Now {
return &Now{t}
}
// BeginningOfYear beginning of year
func BeginningOfYear() time.Time {
return New(time.Now()).BeginningOfYear()
}
// BeginningOfYear BeginningOfYear beginning of year
func (now *Now) BeginningOfYear() time.Time {
y, _, _ := now.Date()
return time.Date(y, time.January, 1, 0, 0, 0, 0, now.Location())
}