Move duration conversion into client/data_formatting.h

Simplify it
Add a test