常用类型及数据操作方法
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

54 lines
729 B

package helper
import (
"strconv"
"strings"
"time"
)
/**
* 星期几索引化
* 2021/02/24
* gz
*/
func GetWeekday() string {
week := []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
var index int
today := time.Now().Weekday().String()
for key, day := range week {
if day == today {
index = key
break
}
}
return strconv.Itoa(index)
}
/**
* 今天是否可用
* weekdays 0,1,2,4
* 2021/02/24
* gz
*/
func TodayCanUse(weekdays string) bool {
if weekdays == "" {
return true
}
days := strings.Split(weekdays, ",")
var can bool = false
today := GetWeekday()
for _, day := range days {
if today == day {
can = true
break
}
}
return can
}