bugfix: handle entries without duration or endtime

This commit is contained in:
2025-11-17 10:54:06 +01:00
parent 8aa4fec9d1
commit b5b78445e1
4 changed files with 13 additions and 6 deletions

View File

@@ -55,9 +55,9 @@ BEGIN {
# Colors # Colors
OFF = "\033[m" OFF = "\033[m"
} }
BEGINFILE { inside = 0; rs = 0; dur = 0; summary = ""; start = "ERROR"; end = "ERROR" } BEGINFILE { inside = 0; rs = 0; dur = 0; summary = ""; start = "ERROR"; end = "" }
{ gsub("\r", "") } { gsub("\r", "") }
/^END:VEVENT/ { print "~", start, dur ? start " " end : end, title(start, summary), fn(FILENAME); nextfile } /^END:VEVENT/ { print "~", start, dur ? start " " end : (end ? end : start), title(start, summary), fn(FILENAME); nextfile }
/^DTSTART/ && inside { start = parse_dt(getparam($0), getcontent($0)) } /^DTSTART/ && inside { start = parse_dt(getparam($0), getcontent($0)) }
/^DTEND/ && inside { end = parse_dt(getparam($0), getcontent($0)) } /^DTEND/ && inside { end = parse_dt(getparam($0), getcontent($0)) }
/^DURATION/ && inside { end = parse_duration($NF); dur = 1 } /^DURATION/ && inside { end = parse_duration($NF); dur = 1 }

View File

@@ -77,6 +77,8 @@ function slice(start, stop, collection, desc, status) {
color = color_from_status(status) color = color_from_status(status)
if (stop == "00:00") if (stop == "00:00")
return collection " " style_timerange start " → " ": " OFF color desc OFF return collection " " style_timerange start " → " ": " OFF color desc OFF
else if (start == stop)
return collection " " style_timerange start " " ": " OFF color desc OFF
else else
return collection " " style_timerange start " " stop ": " OFF color desc OFF return collection " " style_timerange start " " stop ": " OFF color desc OFF
} }

View File

@@ -30,9 +30,13 @@ function print_data(start, dur, end, summary, cmd, collection, depth, path) {
cmd = "date -d '" start "' +\"%s\"" cmd = "date -d '" start "' +\"%s\""
cmd | getline start cmd | getline start
close(cmd) close(cmd)
if (end) {
cmd = "date -d '" end "' +\"%s\"" cmd = "date -d '" end "' +\"%s\""
cmd | getline end cmd | getline end
close(cmd) close(cmd)
} else {
end = start
}
status = status ? status : "CONFIRMED" status = status ? status : "CONFIRMED"
print start, end, fpath, collection, status, summary print start, end, fpath, collection, status, summary
} }

View File

@@ -29,6 +29,7 @@ BEGIN {
$2 == "00:00" && $3 == "00:00" { dayline = dayline " " c($4); next } $2 == "00:00" && $3 == "00:00" { dayline = dayline " " c($4); next }
$2 == "00:00" { dayline = dayline style_time " → " $3 OFF " " c($4); next } $2 == "00:00" { dayline = dayline style_time " → " $3 OFF " " c($4); next }
$3 == "00:00" { dayline = dayline style_time " " $2 " → " OFF c($4); next } $3 == "00:00" { dayline = dayline style_time " " $2 " → " OFF c($4); next }
NF == 4 && $2 == $3 { dayline = dayline style_time " " $2 OFF " " c($4); next }
NF == 4 { dayline = dayline style_time " " $2 " " $3 OFF " " c($4); next } NF == 4 { dayline = dayline style_time " " $2 " " $3 OFF " " c($4); next }
NF == 1 && dayline { print "+", startofweek " +" $1-1 " days", "", dayline } NF == 1 && dayline { print "+", startofweek " +" $1-1 " days", "", dayline }
NF == 1 { NF == 1 {