How to Profile Google Calendar
May. 30th, 2017 10:53 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Here is one way to profile calendars:
- Export calendars in iCalendar format.
- Check out this Awk script:
function parse(dt) { Y = substr(dt, 1, 4); M = substr(dt, 5, 2); D = substr(dt, 7, 2); h = substr(dt, 10, 2); m = substr(dt, 12, 2); s = substr(dt, 14, 2); return Y "/" M "/" D " " h ":" m ":" s; } /^BEGIN:VEVENT/ { dtstart = ""; dtend = ""; summary = ""; } /^DTSTART:/ { sub(/\r$/, ""); sub(/^DTSTART:/, ""); dtstart = parse($0); } /^DTEND:/ { sub(/\r$/, ""); sub(/^DTEND:/, ""); dtend = parse($0); } /^SUMMARY:/ { sub(/\r$/, ""); sub(/^SUMMARY:/, ""); gsub(/ */, " "); summary = $0; } /^END:VEVENT/ { if (dtstart && dtend && summary) { print "i " dtstart " " prefix summary; print "o " dtend; } }
- Have the Ledger utility installed:
sudo apt install ledger # or whatever
-
Convert the exported ICS files to timelog format:
awk -f ics2tc.awk *.ics >timelog.tc
-
Generate various reports from timelog, for example:
ledger -f timelog.tc b -S -T
-
Optionally specify a prefix:
awk -f ics2tc.awk -v prefix=Work: Work.ics >Work.tc
-
Or even create a Makefile like this:
TIMELOGS = Anna.tc David.tc all: $(TIMELOGS) clean: -rm -f $(TIMELOGS) .SUFFIXES: .ics .tc .ics.tc: awk -f ics2tc.awk -v prefix=$*: $< >$@
- ?????
- PROFIT!!1oneone