dot

packages and services management
Log | Files | Refs | README

commit 294ebd4019f0ce814f1004606c67ca26058bf405
parent 7310024635461498d0dfca12841f81f322de5489
Author: josuah <mail@josuah.net>
Date:   Mon, 26 Dec 2016 01:20:24 +0000

Restoring icaldir

Diffstat:
M.config/dvtm/config.h | 2+-
M.local/bin/calendar | 2+-
M.local/bin/icaldir | 69++++++++++++++++++++-------------------------------------------------
3 files changed, 22 insertions(+), 51 deletions(-)

diff --git a/.config/dvtm/config.h b/.config/dvtm/config.h @@ -58,7 +58,7 @@ static Color colors[] = { /* scroll back buffer size in lines */ #define SCROLL_HISTORY 5000 /* printf format string for the tag in the status bar */ -#define TAG_SYMBOL " %s " +#define TAG_SYMBOL "│ %s " /* curses attributes for the currently selected tags */ #define TAG_SEL (COLOR(DEFAULT) | A_BOLD) /* curses attributes for not selected tags which contain no windows */ diff --git a/.local/bin/calendar b/.local/bin/calendar @@ -17,7 +17,7 @@ function days_in_month(month, year) } -function date_to_second(year, month, day, hour, minute, second) +function to_seconds(year, month, day, hour, minute, second) { for (month--; month > 0; month--) day += days_in_month(month, year); diff --git a/.local/bin/icaldir b/.local/bin/icaldir @@ -1,46 +1,4 @@ -awk '# Store an ical file one event per file in a directory, like for maildir - - -function is_bissextile(year) -{ - return (year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0); -} - - -function days_in_month(month, year) -{ - if (month == 2) { - return 28 + is_bissextile(year); - } else if (month < 8) { - return 30 + (month % 2 == 1); - } else { - return 30 + (month % 2 == 0); - } -} - - -function to_seconds(year, month, day, hour, minute, second) -{ - for (month--; month > 0; month--) - day += days_in_month(month, year); - - for (year--; year >= 1970; year--) - day += 365 + is_bissextile(year); - - return (second + 60 * (minute + 60 * (hour + (24 * (day - 1))))); -} - - -function ical_to_seconds(date) -{ - return to_seconds( \ - substr(date, 1, 4), # Year - substr(date, 5, 2), # Month - substr(date, 7, 2), # Day - substr(date, 10, 2), # Hour - substr(date, 12, 2), # Minute - substr(date, 14, 2)); # Second -} +awk -v DIR="$1" '# ical -> one file per event BEGIN { @@ -67,14 +25,27 @@ BEGIN { /END:VEVENT/ { - printf("%s\n", ical_to_seconds(vevent["DTSTART"])); - printf("%s\n", ical_to_seconds(vevent["DTEND"])); + date = vevent["DTSTART"]; + path = DIR "/" \ + substr(date, 1, 4) "-" \ + substr(date, 5, 2) "-" \ + substr(date, 7, 2) "-" \ + substr(date, 10, 2) "-" \ + substr(date, 12, 2); + + date = vevent["DTEND"]; + path = path "--" \ + substr(date, 1, 4) "-" \ + substr(date, 5, 2) "-" \ + substr(date, 7, 2) "-" \ + substr(date, 10, 2) "-" \ + substr(date, 12, 2); gsub(/\\/, "", vevent["LOCATION"]); - printf("%s\t", vevent["SUMMARY"]); + printf("%s\t", vevent["SUMMARY"]) >> path; gsub(/\\/, "", vevent["LOCATION"]); - printf("%s\t", vevent["LOCATION"]); + printf("%s\t", vevent["LOCATION"]) >> path; - print(vevent["DESCRIPTION"]); -}' "$1" + print(vevent["DESCRIPTION"]) >> path; +}' "${2:?Usage: ${0##*/} DIR ICAL}"