dot

packages and services management
Log | Files | Refs | README

commit dfee4ca7cd4c3e737f354f57e36dc3ebd8699ec8
parent c1f1ccbc8068e333380a2e7e2cc205b7773228da
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sat, 23 Dec 2017 13:05:15 +0100

Inline fold function and show when beg/end date differs

Diffstat:
Mbin/agenda | 40++++++++++++++++++----------------------
Rbin/calendar-update -> bin/agenda-update | 0
2 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/bin/agenda b/bin/agenda @@ -104,17 +104,6 @@ BEGIN { }' awk_show=$awk_date'#OFF=[+-]HH -function fold(str) -{ - str = str " "; - while ((l = substr(str, 1, 66)) != "") { - sub(" +[^ ]*$", "", l); - printf(" | %s\n", l); - str = substr(str, length(l) + 1); - sub("^ *", "", str); - } -} - BEGIN { FS = ":"; } @@ -134,17 +123,24 @@ BEGIN { /^:$/ { beg = to_date("%04d/%02d/%02d %02d:%02d", line["B"] + OFF * 3600); end = to_date("%04d/%02d/%02d %02d:%02d", line["E"] + OFF * 3600); - beg_mth = substr(beg, 1, 7); - beg_day = substr(beg, 9, 2); - beg_h_m = substr(beg, 12); - end_h_m = substr(end, 12); - printf("%s\n%2s %s %s\n %2s [%s] %s\n", - (beg_mth != last_mth) ? ("\n\n[" beg_mth "]\n") : "", - (beg_day != last_day) ? (beg_day) : (""), - beg_h_m, line["S"], end_h_m, line["C"], line["L"]); - fold(line["D"]); - last_mth = beg_mth; - last_day = beg_day; + b_mth = substr(beg, 1, 7); + b_day = substr(beg, 9, 2); + e_day = substr(end, 9, 2); + b_h_m = substr(beg, 12); + e_h_m = substr(end, 12); + printf("%s\n%2s %2s %s\n%2s %2s [%s] %s\n", + (b_mth != last_mth) ? ("\n\n[" b_mth "]\n") : "", + (b_day != last_day) ? (b_day) : (""), b_h_m, line["S"], + (b_day != e_day) ? (e_day) : (""), e_h_m, line["C"], line["L"]); + str = line["D"] " "; + while ((l = substr(str, 1, 66)) != "") { + sub(" +[^ ]*$", "", l); + printf(" | %s\n", l); + str = substr(str, length(l) + 1); + sub("^ *", "", str); + } + last_mth = b_mth; + last_day = b_day; }' awk_to_sec=$awk_date'#DATE=YYYY-MM-DD-HH-MM #OFF=[+-]HH diff --git a/bin/calendar-update b/bin/agenda-update