Update timedate handling for Moodle 2.4 and consolidate function