Refactored datetime-related modules and functions to simplify the code.