From: dbucklin@sdf.org Date: 2017-11-10 Subject: Journal to Timesheet A couple tricks I use to keep a work journal and generate daily summaries for my timesheet. Even if you don't need to keep a timesheet, this is a good way to track your accomplishments. When I was a developer, I had to track my time in quarter-hour in- crements. I never really liked doing this but, after 10+ years, it's a tough habit to break. These days, the requirements aren't quite as strict, but I still keep track of what I'm doing through- out the day. It helps me show others what I've been doing and it helps me understand what I've accomplished. This can be very valu- able, say, during scrum meetings or when I have to fill out my timesheet at the end of the week. Journal My journal is a simple text file that I maintain in Vim. Each jour- nal entry goes on one line, and each line follows a consistent for- mat. It looks like this: ``` 1995-10-29 04:28 Back from jail! The feds broke my computer, but I think Cereal forgot about the French fry incident. 1995-10-25 20:47 So, Crash is getting blackmailed. Weird. I gave him some stuff I downloaded from the Gibson and now we are eating pizza. 1995-10-23 03:32 Righteous hack! I hacked a Gibson and I have proof! 1995-10-06 23:52 Nikon told me that hacking a bank across state lines stupid, and now I owe Cereal some fries. 1995-10-04 02:12 Hacked a bank! I'm finally going to get some respect from the guys. 1995-09-15 18:54 Thinking about a handle. Maybe ULTRALaser? ``` As you can see, each line begins with a date and time and includes a short message about, in this example, what Joey Pardella was do- ing in the Fall of 1995. I write my journal in reverse-chronologi- cal order with the most recent entry at the top. I do this, most- ly, because that's where my eyes land when I first look at a docu- ment. Unlike Joey, I usually have several entries per day. So that I'm not writing timestamps manually, I use this mapping in Vim: ``` nnoremap gs :pu! =strftime('%Y-%m-%d %H:%M')A ``` This inserts the timestamp at the beginning of the line and puts me into insert mode. This is handy in other documents, too. When I'm taking notes, I can insert a timestamp quickly. Being able to see these timestamps can be very helpful later on. Summarizing At the end of the week, it's nice to be able to see a daily summary of what I did over the course of the week. For that, I use the fol- lowing script: ```bash #!/usr/bin/bash awk ' BEGIN {FS=" ";ORS="";days=1;prevdt="";msg=""} { dt = $1 if (dt != prevdt) { if (prevdt != "") { print msg "0 days++ if (days>5) exit } print "0 dt "0 prevdt = dt msg = "" } $1 = "";$2 = "" msg = $0 msg }' journal.txt | sed 's/ */ /g;s/^ //' ``` This gathers up the journal entries for the last five days and prints them out as paragraphs. I can run this in the terminal (Git bash, in my case), or from within Vim. Then I just copy and paste the text for each day into my daily timesheet entry. If you create your journal in chronological order, this script can be simplified somewhat. In my case, because awk processes files top-down, I have to accumulate journal entries, prepending, and then print them af- ter the date changes. If I were to treat this as a normal, chrono- logical log file, my summaries will appear in reverse order within each day; it reads a little weird.