add duration calculation function
Merge pull request #1 from krman/duration

Duration