26 lines
563 B
Go
26 lines
563 B
Go
package util
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
func IsToday(t time.Time) bool {
|
|
toDay := time.Now()
|
|
if toDay.Year() == t.Year() && toDay.Month() == t.Month() && toDay.Day() == t.Day() {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
}
|
|
|
|
func GetOneDayBetween(t time.Time) (time.Time, time.Time) {
|
|
startTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
|
|
endTime := time.Date(t.Year(), t.Month(), t.Day(), 23, 59, 59, 0, t.Location())
|
|
return startTime, endTime
|
|
}
|
|
|
|
func ParseTime(layout, str string) time.Time {
|
|
t, _ := time.Parse(layout, str)
|
|
return t
|
|
}
|