|
|
- 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
- }
|