impr: handling of categories

This commit is contained in:
2025-07-04 11:56:27 +02:00
parent e80d9deb79
commit 78d0983464
8 changed files with 106 additions and 68 deletions

View File

@@ -1,7 +1,17 @@
# Retrieve content from iCalendar file
#
# Mandatory variable: `field`.
# Name of field to retrieve.
#
# Optional variable: `format`.
# If `format` is set to "csv", then the content is interpreted as
# comma-separated values, and empty values are dropped.
# If `format` is set to "date", then the content is interpreted as
# a date the output is in the form YYYY-MM-DD.
@include "lib/awk/icalendar.awk"
# print content of field `field`
BEGIN { FS = ":"; regex = "^" field; }
BEGIN { FS = ":"; ORS = ""; regex = "^" field; }
/^BEGIN:(VJOURNAL|VTODO)/ { type = $2 }
/^END:/ && $2 == type { exit }
$0 ~ field { line = $0; next; }
@@ -10,5 +20,22 @@ $0 ~ field { line = $0; next; }
END {
if (!type) { exit }
# Process line
print getcontent(line)
content = getcontent(line)
switch (format) {
case "csv" :
split(content, a, ",")
for (i in a) {
if (a[i])
res = res "," a[i]
}
print substr(res, 2)
break
case "date" :
if (content)
print substr(parse_dt("", content), 1, 10)
break
default :
print content
break
}
}