Refactoring the code in Time.php