Skip to content

Commit

Permalink
新增:ResetDay 抹除天数,将天、小时、分、秒、毫秒 设为0
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed May 8, 2024
1 parent f421724 commit e7e46d8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dateTime/dt.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ func (receiver DateTime) AddMillisecond(millisecond int) DateTime {
return New(receiver.time.Add(time.Duration(millisecond) * time.Millisecond))
}

// ResetDay 抹除天数,将天、小时、分、秒、毫秒 设为0
func (receiver DateTime) ResetDay() DateTime {
return New(time.Date(receiver.Year(),time.Month(receiver.Month()),1,0,0,0,0,time.Local))
}

// Sub 时间相减
func (receiver DateTime) Sub(dt DateTime) time.Duration {
return receiver.time.Sub(dt.time)
Expand Down

0 comments on commit e7e46d8

Please sign in to comment.