Improved datetime parsing