Fix display of rules missing day when format is "@day;xxxx-yyyy"

This commit is contained in:
Rob Pearce 2022-06-16 19:21:32 +10:00
parent e7fcc08091
commit cbb62548fc
1 changed files with 26 additions and 3 deletions

View File

@ -927,6 +927,25 @@ function weekdaytonum() {
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() {
error "Invalid condition: $1"
echo -e "${RED} Start: $2"
@ -1028,6 +1047,10 @@ function processtimeconditions() {
fi
endh="$starth"
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
stype[0]=$(getstrtype ${ttok[0]})
stype[1]=$(getstrtype ${ttok[1]})
@ -1055,7 +1078,7 @@ function processtimeconditions() {
return 1
fi
nowh=$(date +%u)
if [[ ${ttok[1]} == ${ttok[2]} ]]; then
if [[ ${ttok[0]} == ${ttok[1]} ]]; then
[[ -n $timestr_human ]] && this_human="o " || this_human=O
this_human=$(printf "${this_human}n _H_%ss_EH_" ${ttok[0]})
else
@ -1066,7 +1089,7 @@ function processtimeconditions() {
conderror "${cond}" "'${ttok[0]}' (${stype[0]})" "'${ttok[1]}' (${stype[1]})"
return 1
fi
fi
fi # end if ttokcount
if [[ -n $starth ]]; then
[[ $db -eq 1 ]] && info " check if $nowh is between $starth and $endh"
ok=0
@ -1086,7 +1109,7 @@ function processtimeconditions() {
[[ $ok -eq 0 ]] && nonmatches=$((nonmatches + 1))
[[ $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"
fi
fi # end if condition matches
timestr_human="${timestr_human}${this_human}"
if [[ $ok -eq 0 && $keepgoing -eq 0 ]]; then
break