StringUtils.go 648 Bytes
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
}