Improved FormatTimeString implementation, added unit tests.