Fix display of rules missing day when format is "@day;xxxx-yyyy"
This commit is contained in:
parent
e7fcc08091
commit
cbb62548fc
29
aircon.sh
29
aircon.sh
|
@ -927,6 +927,25 @@ function weekdaytonum() {
|
||||||
echo "$num"
|
echo "$num"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function weekdaytofull() {
|
||||||
|
local full
|
||||||
|
shopt -s nocasematch
|
||||||
|
num=-1
|
||||||
|
case "$1" in
|
||||||
|
"mon") full="Monday";;
|
||||||
|
"tue") full="Tuesday";;
|
||||||
|
"wed") full="Wednesday";;
|
||||||
|
"thu") full="Thursday";;
|
||||||
|
"fri") full="Friday";;
|
||||||
|
"sat") full="Saturday";;
|
||||||
|
"sun") full="Sunday";;
|
||||||
|
esac
|
||||||
|
shopt -u nocasematch
|
||||||
|
echo "$full"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function conderror() {
|
function conderror() {
|
||||||
error "Invalid condition: $1"
|
error "Invalid condition: $1"
|
||||||
echo -e "${RED} Start: $2"
|
echo -e "${RED} Start: $2"
|
||||||
|
@ -1028,6 +1047,10 @@ function processtimeconditions() {
|
||||||
fi
|
fi
|
||||||
endh="$starth"
|
endh="$starth"
|
||||||
nowh=$(date +%u)
|
nowh=$(date +%u)
|
||||||
|
|
||||||
|
[[ -n $timestr_human ]] && this_human="o " || this_human=O
|
||||||
|
this_human=$(printf "${this_human}n _H_%ss_EH_" $(weekdaytofull ${ttok[0]}))
|
||||||
|
|
||||||
else
|
else
|
||||||
stype[0]=$(getstrtype ${ttok[0]})
|
stype[0]=$(getstrtype ${ttok[0]})
|
||||||
stype[1]=$(getstrtype ${ttok[1]})
|
stype[1]=$(getstrtype ${ttok[1]})
|
||||||
|
@ -1055,7 +1078,7 @@ function processtimeconditions() {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
nowh=$(date +%u)
|
nowh=$(date +%u)
|
||||||
if [[ ${ttok[1]} == ${ttok[2]} ]]; then
|
if [[ ${ttok[0]} == ${ttok[1]} ]]; then
|
||||||
[[ -n $timestr_human ]] && this_human="o " || this_human=O
|
[[ -n $timestr_human ]] && this_human="o " || this_human=O
|
||||||
this_human=$(printf "${this_human}n _H_%ss_EH_" ${ttok[0]})
|
this_human=$(printf "${this_human}n _H_%ss_EH_" ${ttok[0]})
|
||||||
else
|
else
|
||||||
|
@ -1066,7 +1089,7 @@ function processtimeconditions() {
|
||||||
conderror "${cond}" "'${ttok[0]}' (${stype[0]})" "'${ttok[1]}' (${stype[1]})"
|
conderror "${cond}" "'${ttok[0]}' (${stype[0]})" "'${ttok[1]}' (${stype[1]})"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi # end if ttokcount
|
||||||
if [[ -n $starth ]]; then
|
if [[ -n $starth ]]; then
|
||||||
[[ $db -eq 1 ]] && info " check if $nowh is between $starth and $endh"
|
[[ $db -eq 1 ]] && info " check if $nowh is between $starth and $endh"
|
||||||
ok=0
|
ok=0
|
||||||
|
@ -1086,7 +1109,7 @@ function processtimeconditions() {
|
||||||
[[ $ok -eq 0 ]] && nonmatches=$((nonmatches + 1))
|
[[ $ok -eq 0 ]] && nonmatches=$((nonmatches + 1))
|
||||||
[[ $db -eq 1 && $ok -eq 0 ]] && info " $nowh isn't in range $cond"
|
[[ $db -eq 1 && $ok -eq 0 ]] && info " $nowh isn't in range $cond"
|
||||||
[[ $db -eq 1 && $ok -eq 1 ]] && info " MATCH: $nowh within range $cond"
|
[[ $db -eq 1 && $ok -eq 1 ]] && info " MATCH: $nowh within range $cond"
|
||||||
fi
|
fi # end if condition matches
|
||||||
timestr_human="${timestr_human}${this_human}"
|
timestr_human="${timestr_human}${this_human}"
|
||||||
if [[ $ok -eq 0 && $keepgoing -eq 0 ]]; then
|
if [[ $ok -eq 0 && $keepgoing -eq 0 ]]; then
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue