clead awk script a bit

This commit is contained in:
Ämin Baumeler 2025-06-10 13:08:45 +02:00
parent 5586619abf
commit 54b10ad726

View File

@ -1,16 +1,16 @@
# 11:00|13:00|1748422800|1748430000|fpath|desc...
# 00:00|00:00|1748296800|1748383200|fpath|desc...
function allday() {
return ITALIC FAINT " (allday) " OFF $6
function allday(desc) {
return ITALIC FAINT " (allday) " OFF desc
}
function endstoday() {
return CYAN " -- " $2 OFF ": " $6
function endstoday(stop, desc) {
return CYAN " -- " stop OFF ": " desc
}
function slice() {
if ($2 == "00:00")
return CYAN $1 " -- " OFF ": " $6
function slice(start, stop, desc) {
if (stop == "00:00")
return CYAN start " -- " OFF ": " desc
else
return CYAN $1 OFF " -- " CYAN $2 OFF ": " $6
return CYAN start OFF " -- " CYAN stop OFF ": " desc
}
function hrline(hour) {
print hour, "", "", "", FAINT hour ":00 ----------------------" OFF
@ -25,23 +25,23 @@ function hrlines(start, stop, h, starth, stoph, tmp, i) {
return stoph + tmp
}
BEGIN {
FS = "|";
FS = "|"
daystart = 8
dayend = 18
GREEN = "\033[1;32m";
RED = "\033[1;31m";
WHITE = "\033[1;97m";
CYAN = "\033[1;36m";
ITALIC = "\033[3m";
FAINT = "\033[2m";
OFF = "\033[m";
GREEN = "\033[1;32m"
RED = "\033[1;31m"
WHITE = "\033[1;97m"
CYAN = "\033[1;36m"
ITALIC = "\033[3m"
FAINT = "\033[2m"
OFF = "\033[m"
OFS = "|"
}
$1 == "00:00" && $2 == "00:00" { print $1, $3, $4, $5, allday(); next }
$1 == "00:00" { print $1, $3, $4, $5, endstoday(); next }
$1 == "00:00" && $2 == "00:00" { print $1, $3, $4, $5, allday($6); next }
$1 == "00:00" { print $1, $3, $4, $5, endstoday($2, $6); next }
$1 ~ /^[0-9]{2}:[0-9]{2}$/ {
daystart = hrlines($1, $2, daystart, starth, stoph, tmp, i)
print $1, $3, $4, $5, slice()
print $1, $3, $4, $5, slice($1, $2, $6)
}
END {
hrlines(dayend":00", 0, daystart, starth, stoph, tmp, i)