fix day view

This commit is contained in:
Ämin Baumeler 2025-06-10 13:06:00 +02:00
parent 801108c70c
commit 5586619abf
2 changed files with 27 additions and 13 deletions

View File

@ -15,8 +15,19 @@ function slice() {
function hrline(hour) {
print hour, "", "", "", FAINT hour ":00 ----------------------" OFF
}
function hrlines(start, stop, h, starth, stoph, tmp, i) {
starth = substr(start, 1, 2)
stoph = substr(stop, 1, 2)
tmp = substr(start, 4, 2) == "00" ? 0 : 1
for (i=h; i < starth + tmp; i++)
hrline(i)
tmp = substr(stop, 4, 2) == "00" ? 0 : 1
return stoph + tmp
}
BEGIN {
FS = "|";
daystart = 8
dayend = 18
GREEN = "\033[1;32m";
RED = "\033[1;31m";
WHITE = "\033[1;97m";
@ -26,10 +37,12 @@ BEGIN {
OFF = "\033[m";
OFS = "|"
}
/^[0-9]+$/ && hour { hrline(hour) }
/^[0-9]+$/ { hour = $1 < 10 ? "0"$1 : $1; next }
$1 == hour":00" { print $1, $3, $4, $5, slice(); unset hour; next }
$1 == "00:00" && $2 == "00:00" { print $1, $3, $4, $5, allday(); next }
$1 == "00:00" { print $1, $3, $4, $5, endstoday();next }
hour { hrline(hour); print $1, $3, $4, $5, slice(); unset hour; next }
{ print $1, $3, $4, $5, slice(); unset hour; next }
$1 == "00:00" && $2 == "00:00" { print $1, $3, $4, $5, allday(); next }
$1 == "00:00" { print $1, $3, $4, $5, endstoday(); next }
$1 ~ /^[0-9]{2}:[0-9]{2}$/ {
daystart = hrlines($1, $2, daystart, starth, stoph, tmp, i)
print $1, $3, $4, $5, slice()
}
END {
hrlines(dayend":00", 0, daystart, starth, stoph, tmp, i)
}

View File

@ -176,12 +176,7 @@ __show_day() {
echo "$s|$e|$starttime|$endtime|$fpath|$description"
done)
fi
#echo "||||🗓️ $GREEN $(date -d "$DISPLAY_DATE" +"%a %e %b %Y")$OFF"
#echo ""
(
echo "$sef"
seq 8 18
) | sort -n | awk "$AWK_DAYVIEW"
echo "$sef" | sort -n | awk "$AWK_DAYVIEW"
}
__list() {
@ -325,6 +320,12 @@ if [ "${1:-}" = "--preview" ]; then
exit
fi
if [ "${1:-}" = "--day-reload" ]; then
echo "Jumping to day $DISPLAY_DATE!"
__show_day
exit
fi
if [ "${1:-}" = "--day" ]; then
DISPLAY_DATE="$2"
echo "Jumping to day $DISPLAY_DATE!"