Add toDuration helper

- Update documentation
- Add tests