2019-07-17 12:42:00 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
// Package date contains various date-related utilities
|
|
|
|
package date
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
2019-08-08 14:47:04 +01:00
|
|
|
// MonthBoundary extract month from the provided date and returns its edges
|
|
|
|
func MonthBoundary(t time.Time) (time.Time, time.Time) {
|
|
|
|
startDate := time.Date(t.Year(), t.Month(), 1, 0, 0, 0, 0, t.Location())
|
|
|
|
endDate := time.Date(t.Year(), t.Month()+1, 1, 0, 0, 0, -1, t.Location())
|
|
|
|
return startDate, endDate
|
2019-07-17 12:42:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// DayBoundary returns start and end of the provided day
|
|
|
|
func DayBoundary(t time.Time) (time.Time, time.Time) {
|
2019-08-08 14:47:04 +01:00
|
|
|
return time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location()),
|
|
|
|
time.Date(t.Year(), t.Month(), t.Day()+1, 0, 0, 0, -1, t.Location())
|
2019-07-17 12:42:00 +01:00
|
|
|
}
|