Using painless to calculate durations

One for the logstash forums I expect.