Skip to content

Commit

Permalink
feat: start, end of hour and minute
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad Fikrizaman Bin Abd Rahim committed May 6, 2020
1 parent 223a865 commit 660c805
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions carbon.go
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,26 @@ func (c *Carbon) DiffForHumans(d *Carbon, abs, absolute, short bool) (string, er
return c.Translator.chooseTrans(transID, t), nil
}

// StartOfHour returns the time at the start of every hour
func (c *Carbon) StartOfMinute() *Carbon {
return create(c.Year(), c.Month(), c.Day(), c.Hour(), c.Minute(), 0, 0, c.Location())
}

// EndOfHour returns the time at the start of every hour
func (c *Carbon) EndOfMinute() *Carbon {
return create(c.Year(), c.Month(), c.Day(), c.Hour(), c.Minute(), 59, maxNSecs, c.Location())
}

// StartOfHour returns the time at the start of every hour
func (c *Carbon) StartOfHour() *Carbon {
return create(c.Year(), c.Month(), c.Day(), c.Hour(), 0, 0, 0, c.Location())
}

// EndOfHour returns the time at the start of every hour
func (c *Carbon) EndOfHour() *Carbon {
return create(c.Year(), c.Month(), c.Day(), c.Hour(), 59, 59, maxNSecs, c.Location())
}

// StartOfDay returns the time at 00:00:00 of the same day
func (c *Carbon) StartOfDay() *Carbon {
return create(c.Year(), c.Month(), c.Day(), 0, 0, 0, 0, c.Location())
Expand Down

0 comments on commit 660c805

Please sign in to comment.