dot

packages and services management
Log | Files | Refs | README

commit c5cf94b8862bbbb0c1233b6669d09b9326158e6a
parent 8a620db48832190dda990b856dc0675476bb36ba
Author: Josuah Demangeon <mail@josuah.net>
Date:   Fri, 22 Dec 2017 11:42:51 +0100

more compact format

Diffstat:
Mbin/calendar | 32++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/bin/calendar b/bin/calendar @@ -4,7 +4,6 @@ CALENDAR="$HOME/var/cal" awk_date=' - function bissextile(yrs) { return yrs % 4 == 0 && (yrs % 100 != 0 || yrs % 400 == 0); @@ -71,9 +70,7 @@ function ical(str) { return to_sec(yrs, mth, day, hrs, min, 0); }' -awk_import=$awk_date' -#-v OFF=[+-]HH - +awk_import=$awk_date'#OFF=[+-]HH BEGIN { FS = "[:;]"; } @@ -95,30 +92,28 @@ BEGIN { /END:VEVENT/ { gsub("<[a-zA-Z0-9/]*>", "", event["DESCRIPTION"]); - gsub("\\\\n", "\n:D:", event["DESCRIPTION"]); - printf(":T:%d %d\n:S:%s\n:C:%s\n:L:%s\n:D:%s\n:\n", - ical(event["DTSTART"]) + OFF * 3600, - ical(event["DTEND"]) + OFF * 3600, + gsub("\\\\n", "\nD:", event["DESCRIPTION"]); + printf("T:%d %d\nS:%s\nC:%s\nL:%s\nD:%s\n:\n", + ical(event["DTSTART"]) - OFF * 3600, + ical(event["DTEND"]) - OFF * 3600, event["SUMMARY"], event["CATEGORIES"], event["LOCATION"], event["DESCRIPTION"]); }' -awk_sort=' -# -v SORT=[0SCL] - +awk_sort='#SORT=[TSCL] BEGIN { FS=":" sort = "sort | cut -f " length(SORT) + 2 "-"; } -/^:T:/ { +/^T:/ { nb = 1; line["T"] = line["S"] = line["C"] = line["L"] = line["D"] = ""; } -/^:[TSCLD]:/ { +/^[TSCLD]:/ { line[nb++] = sprintf("%08d\t%s", NR, $0); - line[$2] = substr($0, 4); + line[$1] = substr($0, 3); } /^:$/ { @@ -130,6 +125,15 @@ BEGIN { printf("%s%s\n", prefix, line[i]) | sort; }' +awk_show=$awk_date' +/^[TSCLD]:/ { + line[$1] = substr($0, 4); +} + +/^:$/ { + date = to_date("%04d/%02d/%02d %02d:%02d"); +}' + mkdir -p "$CALENDAR" case $1 in