ApproxDuration refactor

The approxDuration() template function has been refactored to simplify the logic and fix a potential rounding error when the duration is very close to 1 day or 1 year.