feat(utils):增加一个用于判断是否是下一个月的工具函数。
This commit is contained in:
parent
2d1196c703
commit
8283eca993
|
@ -9,3 +9,15 @@ func VeryBeginOfDate(date time.Time) time.Time {
|
|||
func VeryEndOfDate(date time.Time) time.Time {
|
||||
return time.Date(date.Year(), date.Month(), date.Day(), 23, 59, 59, 999999999, date.Location())
|
||||
}
|
||||
|
||||
func IsNextMonth(t1, t2 time.Time) bool {
|
||||
var differYear, differMonth int
|
||||
if t1.After(t2) {
|
||||
differYear = t1.Year() - t2.Year()
|
||||
differMonth = int(t1.Month() - t2.Month())
|
||||
} else {
|
||||
differYear = t2.Year() - t1.Year()
|
||||
differMonth = int(t2.Month() - t1.Month())
|
||||
}
|
||||
return (differMonth == -11 && differYear == 1) || (differMonth == 1 && differYear == 0)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user