[personal profile] codedot

Here is one way to profile calendars:

  1. Export calendars in iCalendar format.
  2. 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;
    	}
    }
    

  3. Have the Ledger utility installed:
    sudo apt install ledger # or whatever
  4. Convert the exported ICS files to timelog format:
    awk -f ics2tc.awk *.ics >timelog.tc
  5. Generate various reports from timelog, for example:
    ledger -f timelog.tc b -S -T
  6. Optionally specify a prefix:
    awk -f ics2tc.awk -v prefix=Work: Work.ics >Work.tc
  7. 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=$*: $< >$@
    

  8. ?????
  9. PROFIT!!1oneone

Profile

Anton Salikhmetov

November 2018

S M T W T F S
    123
45678 910
11121314151617
18192021222324
252627282930 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 24th, 2025 09:27 am
Powered by Dreamwidth Studios