mirror of
https://github.com/miguelmota/cointop
synced 2024-11-16 21:25:38 +00:00
25 lines
470 B
Go
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())
|
||
|
}
|