t display --format csv > tmp.csv
Write tsv file with
#!/data/data/com.termux/files/usr/bin/ruby
require 'csv'
CSV.open(ARGV[0]).each do |r|
puts r.map{ |c| (c || "").gsub(/\t/,'\\t').gsub(/\n/,'\\n') }.join("\t")
end
Feed tsv to
# Process tsv generated from timetrap.rb display output
# into yaml for use with a LaTeX invoice.
BEGIN {
FS = "\t"
}
# String manipulations to turn timetrap's dates
# into gawk datespecs and thence into
# seconds since the epoch.
function sste(timestring) {
gsub("-"," ",timestring)
gsub(":"," ",timestring)
timestring=mktime(timestring)
return timestring / 3600
}
# Calculate duration and
# round it to precision 1.
function duration(t1,t2) {
ts1=sste(t1)
ts2=sste(t2)
# This printf expression rounds to precision 1
printf "%.*f", 1, ts2 - ts1
}
{
if (NR==1) { next }
tstart=$1
tend=$2
note=$3
duration(tstart,tend)
print " " note
}
# TODO:
# - roll each record into an array and
# use END block to calculate totals
# as well as iterate through each line
- Generate yam for invoices.