Refactored timezone detection and adjustment