cleaned awk scripts, str escape bugfix, proper use of local variables
This commit is contained in:
@@ -1,23 +1,35 @@
|
||||
## src/awk/weekview.awk
|
||||
## Print view of all appointments of the current week.
|
||||
##
|
||||
## @assign startofweek: Date of first day in the week
|
||||
|
||||
# Functions
|
||||
|
||||
# c
|
||||
# Compose line that will display a day in the week.
|
||||
#
|
||||
# @return: Single-line string
|
||||
function c() {
|
||||
return CYAN substr($0, index($0, ">") + 1) OFF " " RED "/" OFF
|
||||
}
|
||||
|
||||
# AWK program
|
||||
|
||||
BEGIN {
|
||||
GREEN = "\033[1;32m";
|
||||
RED = "\033[1;31m";
|
||||
WHITE = "\033[1;97m";
|
||||
CYAN = "\033[1;36m";
|
||||
FAINT = "\033[2m";
|
||||
OFF = "\033[m";
|
||||
GREEN = "\033[1;32m"
|
||||
RED = "\033[1;31m"
|
||||
CYAN = "\033[1;36m"
|
||||
OFF = "\033[m"
|
||||
OFS = "|"
|
||||
}
|
||||
/^[0-7] 00:00 -- 00:00/ { dayline = dayline " " c(); next }
|
||||
/^[0-7] 00:00 -- / { dayline = dayline " <--" $4 " " c(); next }
|
||||
/^[0-7] [0-9]{2}:[0-9]{2} -- 00:00/ { dayline = dayline " " $2 "→" c(); next }
|
||||
/^[0-7] 00:00 -- 00:00/ { dayline = dayline " " c(); next }
|
||||
/^[0-7] 00:00 -- / { dayline = dayline " <--" $4 " " c(); next }
|
||||
/^[0-7] [0-9]{2}:[0-9]{2} -- 00:00/ { dayline = dayline " " $2 "→" c(); next }
|
||||
/^[0-7] [0-9]{2}:[0-9]{2} -- [0-9]{2}:[0-9]{2}/ { dayline = dayline " " $2 " - " $4 " " c(); next }
|
||||
/^[0-7]$/ && dayline { print "+", startofweek " +" $0-1 " days", "", dayline; }
|
||||
/^[0-7]$/ && dayline { print "+", startofweek " +" $0-1 " days", "", dayline }
|
||||
/^[0-7]$/ {
|
||||
cmd = "date -d '" startofweek " +" $0 " days' +\"%a %e %b %Y\"";
|
||||
cmd | getline dayline;
|
||||
close(cmd);
|
||||
cmd = "date -d '" startofweek " +" $0 " days' +\"%a %e %b %Y\""
|
||||
cmd | getline dayline
|
||||
close(cmd)
|
||||
dayline = GREEN dayline ": " OFF
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user