25 lines
603 B
Go
25 lines
603 B
Go
package utils
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
func VeryBeginOfDate(date time.Time) time.Time {
|
|
return time.Date(date.Year(), date.Month(), date.Day(), 0, 0, 0, 0, date.Location())
|
|
}
|
|
|
|
func VeryEndOfDate(date time.Time) time.Time {
|
|
return time.Date(date.Year(), date.Month(), date.Day(), 23, 59, 59, 999999999, date.Location())
|
|
}
|
|
|
|
func DifferenceInMonth(t1, t2 time.Time) int {
|
|
var differYear, differMonth int
|
|
differYear = t1.Year() - t2.Year()
|
|
differMonth = int(t1.Month() - t2.Month())
|
|
return differYear*12 + differMonth
|
|
}
|
|
|
|
func IsNextMonth(t1, t2 time.Time) bool {
|
|
return DifferenceInMonth(t1, t2) == -1
|
|
}
|