fzf-vcal/src/awk/weekview.awk

39 lines
1.1 KiB
Awk
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## src/awk/weekview.awk
## Print view of all appointments of the current week.
## Generates view from
## printf "%s\t%s\t%s\t%s\n" "$i" "$s" "$e" "$description"
##
## @assign startofweek: Date of first day in the week
# Functions
# Compose line that will display a day in the week.
#
# @input desc: String with a description of the event
# @return: Single-line string
function c(desc) {
return CYAN desc OFF " " RED "/" OFF
}
# AWK program
BEGIN {
FS = "\t"
OFS = "\t"
GREEN = "\033[1;32m"
RED = "\033[1;31m"
CYAN = "\033[1;36m"
OFF = "\033[m"
}
$2 == "00:00" && $3 == "00:00" { dayline = dayline " " c($4); next }
$2 == "00:00" { dayline = dayline " → " $3 " " c($4); next }
$3 == "00:00" { dayline = dayline " " $2 " → " c($4); next }
NF == 4 { dayline = dayline " " $2 " " $3 " " c($4); next }
NF == 1 && dayline { print "+", startofweek " +" $1-1 " days", "", dayline }
NF == 1 {
cmd = "date -d '" startofweek " +" $1 " days' +\"%a %e %b %Y\""
cmd | getline dayline
close(cmd)
dayline = GREEN dayline ": " OFF
}