StringUtils.go
648 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package utils
import (
"time"
"github.com/satori/go.uuid"
)
/*
获取UUID
*/
func GetUuid() (id string) {
u1 := uuid.NewV4()
id = u1.String()
return
}
func IsValidTime(startTime, endTime time.Time) bool {
now := time.Now()
if now.After(startTime) && now.Before(endTime) {
return true
}
return false
}
func IsValidTimeStr(startStr, endStr string) bool {
now := time.Now()
start, err := time.Parse("2006-01-02 15:04:05", startStr)
if err != nil {
return false
}
end, err := time.Parse("2006-01-02 15:04:05", endStr)
if err != nil {
return false
}
if now.After(start) && now.Before(end) {
return true
}
return false
}